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
;
81 char Buffer1
[BUFFER_SIZE
];
82 char Buffer2
[BUFFER_SIZE
];
85 if (SHArg(NAME
) != NULL
)
87 Success
= DeleteVar(SHArg(NAME
), GVF_LOCAL_ONLY
| LV_ALIAS
);
91 PrintFault(IoErr(), "Unalias");
98 /* Display a list of aliases.
100 UnaliasProc
= (struct Process
*)FindTask(NULL
);
102 if (UnaliasProc
!= NULL
)
104 ForeachNode(&(UnaliasProc
->pr_LocalVars
), UnaliasNode
)
106 if (UnaliasNode
->lv_Node
.ln_Type
== LV_ALIAS
)
108 /* Get a clean variable with no excess
112 VarLength
= GetVar(UnaliasNode
->lv_Node
.ln_Name
,
115 GVF_LOCAL_ONLY
| LV_ALIAS
);
119 GetNewString(&Buffer1
[0],
123 Buffer2
[VarLength
] = 0;
125 Printf("%-20s\t%-20s\n", UnaliasNode
->lv_Node
.ln_Name
, Buffer2
);
138 void GetNewString(STRPTR s
, STRPTR d
, LONG l
)
147 if (s
[i
] == '*' || s
[i
] == '\e')