Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Shift

Built-in

SYNTAX

Shift [number]

DESCRIPTION

The Shift command renames the command script positional parameters {number+1}, {number+2}… to {1}, {2}, and so on. If you do not specify number, Shift uses 1 as the default. This makes parameter {2} become {1}, parameter {3} become {2}, and so on. This is especially useful for stepping down parameters in scripts using a loop.

Note that although this command does not affect parameter {0} (the command name), it does modify the {Parameters}, {"Parameters"}, and {#} variables to reflect the new parameters.

INPUT

None

OUTPUT

None

STATUS

Shift can return the following status codes:

0

no errors

1

syntax error

PARAMETERS

number

Specifies the number in the parameters {number+1}, {number+2}, and so on. If you omit this parameter, Shift assumes that number is 1.

OPTIONS

None

EXAMPLES

The following script uses Shift to repeat a command once for each parameter. Break stops the loop when all the parameters have been used.

# Execute command once for each parameter in the
# parameter list. You can specify options by
# including them in quotes with the command name.
Set cmd "{1}"
Loop
  Shift
  Break If "{1}" == ""
  "{cmd}" "{1}"
End

You might, for example, use the following Repeat script to compile several C programs with progress information:

Repeat 'SC -p' Sample.c Count.c Memory.c

 
 


Last Updated July 2000