2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
8 /*****************************************************************************
24 Removes a previously defined shell alias.
26 If no parameters are specified, the current list of aliases are
31 NAME - The name of the alias to unset.
35 Standard DOS error codes.
51 ******************************************************************************/
54 #include <proto/dos.h>
55 #include <proto/exec.h>
58 #include <dos/dosextens.h>
59 #include <dos/rdargs.h>
61 #include <exec/lists.h>
62 #include <exec/nodes.h>
63 #include <exec/types.h>
66 #include <aros/shcommands.h>
68 #define BUFFER_SIZE 160
70 void GetNewString(STRPTR
, STRPTR
, LONG
);
72 AROS_SH1(Unalias
, 41.0,
73 AROS_SHA(STRPTR
, ,NAME
, ,NULL
))
77 struct Process
* UnaliasProc
;
78 struct LocalVar
* UnaliasNode
;
82 char Buffer1
[BUFFER_SIZE
];
83 char Buffer2
[BUFFER_SIZE
];
86 if (SHArg(NAME
) != NULL
)
88 Success
= DeleteVar(SHArg(NAME
), GVF_LOCAL_ONLY
| LV_ALIAS
);
92 PrintFault(IoErr(), "Unalias");
99 /* Display a list of aliases.
101 UnaliasProc
= (struct Process
*)FindTask(NULL
);
103 if (UnaliasProc
!= NULL
)
105 ForeachNode(&(UnaliasProc
->pr_LocalVars
), UnaliasNode
)
107 if (UnaliasNode
->lv_Node
.ln_Type
== LV_ALIAS
)
109 /* Get a clean variable with no excess
113 VarLength
= GetVar(UnaliasNode
->lv_Node
.ln_Name
,
116 GVF_LOCAL_ONLY
| LV_ALIAS
);
120 GetNewString(&Buffer1
[0],
124 Buffer2
[VarLength
] = NULL
;
126 OutArgs
[0] = (IPTR
)UnaliasNode
->lv_Node
.ln_Name
;
127 OutArgs
[1] = (IPTR
)&Buffer2
[0];
128 OutArgs
[2] = (IPTR
)NULL
;
129 VPrintf("%-20s\t%-20s\n", &OutArgs
[0]);
142 void GetNewString(STRPTR s
, STRPTR d
, LONG l
)
151 if (s
[i
] == '*' || s
[i
] == '\e')