2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
8 /*****************************************************************************
24 Set a local environment variable in the current shell. If any global
25 variables have the same name the local variable will be used instead.
27 This instance the variable is only accessible from within the shell
30 If no parameters are specified, the current list of local variables
35 NAME - The name of the local variable to set.
37 STRING - The value of the local variable NAME.
41 Standard DOS error codes.
49 Sets a local variable called "Jump" to the value of "5".
59 ******************************************************************************/
62 #include <proto/dos.h>
63 #include <proto/exec.h>
66 #include <dos/dosextens.h>
67 #include <dos/rdargs.h>
69 #include <exec/lists.h>
70 #include <exec/nodes.h>
71 #include <exec/types.h>
72 #include <aros/shcommands.h>
74 #define BUFFER_SIZE 160
76 static void GetNewString(STRPTR
, STRPTR
, LONG
);
79 AROS_SHA(STRPTR
, ,NAME
, , NULL
),
80 AROS_SHA(STRPTR
, ,STRING
, /F
, NULL
))
84 struct Process
* SetProc
;
85 struct LocalVar
* SetNode
;
87 char Buffer1
[BUFFER_SIZE
];
88 char Buffer2
[BUFFER_SIZE
];
91 if (SHArg(NAME
) != NULL
|| SHArg(STRING
) != NULL
)
93 /* Make sure we get to here is either arguments are
94 * provided on the command line.
96 if (SHArg(NAME
) != NULL
&& SHArg(STRING
) != NULL
)
98 /* Add the new local variable to the list.
114 SetProc
= (struct Process
*)FindTask(NULL
);
116 ForeachNode(&(SetProc
->pr_LocalVars
), SetNode
)
118 if (SetNode
->lv_Node
.ln_Type
== LV_VAR
)
120 /* Get a clean variable with no excess
124 VarLength
= GetVar(SetNode
->lv_Node
.ln_Name
,
131 GetNewString(&Buffer1
[0],
136 Buffer2
[VarLength
] = 0;
138 Printf("%-20s\t%-20s\n", SetNode
->lv_Node
.ln_Name
, Buffer2
);
149 static void GetNewString(STRPTR s
, STRPTR d
, LONG l
)
158 if (s
[i
] == '*' || s
[i
] == '\e')