shift command
Shifts the contents of the command line argument variables.
Usages
-
shift
This command shifts the contents of the special variables containing the script arguments “to the left”, so the value of $arg0 is thrown away, $arg1 becomes $arg0, $arg2 becomes $arg1, and so on.
This lets you process arguments in a loop, by examining $arg0, then using shift.
Examples
while ($arg0 != "") echo Next argument is $arg0 shift end
When executing a script file (script.cmd), with the command line "script.cmd a b c d", we have $argc = 5, $arg0 = script.cmd, $arg1 = a, $arg2 = b, $arg3 = c, $arg4 = d. After the shift command, $argc = 4, $arg0 = a, $arg1 = b, $arg2 = c, $arg3 = d.