static cmd_function_t *cmd_functions; // possible commands to execute
+/*
+============
+Cmd_ExecuteAlias
+
+Called for aliases and fills in the alias into the cbuffer
+============
+*/
+static void Cmd_ExecuteAlias (cmdalias_t *alias)
+{
+ const char *text = alias->value;
+
+ while( COM_ParseTokenConsole( &text ) )
+ {
+ Cbuf_AddText( "\"" );
+
+ if( com_token[0] == '$' )
+ {
+ int argNum;
+ argNum = atoi( &com_token[1] );
+
+ // no number at all?
+ if( argNum == 0 )
+ {
+ Cbuf_AddText( com_token );
+ }
+ else if( argNum >= Cmd_Argc() )
+ {
+ Con_Printf( "Warning: Not enough parameters passed to alias '%s', at least %i expected:\n %s\n", alias->name, argNum, alias->value );
+ Cbuf_AddText( com_token );
+ }
+ else
+ {
+ Cbuf_AddText( Cmd_Argv( argNum ) );
+ }
+ }
+ else
+ {
+ Cbuf_AddText( com_token );
+ }
+
+ Cbuf_AddText( "\"" );
+ }
+ Cbuf_AddText( "\n" );
+}
+
/*
========
Cmd_List
if (!COM_ParseTokenConsole(&text))
return;
+ // check for $cvar
+ // (perhaps use another target buffer?)
+ if (com_token[0] == '$' && com_token[1])
+ {
+ cvar_t *cvar;
+
+ cvar = Cvar_FindVar(&com_token[1]);
+ if (cvar)
+ {
+ strcpy(com_token, cvar->string);
+ }
+ else if( com_token[1] == '$' )
+ {
+ // remove the first $
+ char *pos;
+
+ for( pos = com_token ; *pos ; pos++ )
+ {
+ *pos = *(pos + 1);
+ }
+ }
+ }
+
if (cmd_argc < MAX_ARGS)
{
l = (int)strlen(com_token) + 1;
{
if (!strcasecmp (cmd_argv[0], a->name))
{
- Cbuf_InsertText (a->value);
+ Cmd_ExecuteAlias(a);
cmd_tokenizebufferpos = oldpos;
return;
}