aboutsummaryrefslogtreecommitdiffstats
execline: the shift program

execline
Software
www.skarnet.org

The shift program

shift shifts the positional parameters of an execline script.

Interface

     shift [ -n argn ] [ -b blockn ] prog...
  • shift shifts argn positional parameters, then blockn blocks. It then execs prog....
  • By default, argn and blockn are both zero; but if neither the -n nor the -b option is given, then argn is 1 and blockn is 0.

Details

  • shift reads the number of "positional parameters" in the # environment variable. Let n be that number.
  • If the # environment variable is not set or does not contain a valid number, or one of the 0, 1, ..., n environment variables is not set, shift exits 100 with an error message.
  • shift calculates a shift value m, corresponding to argn arguments followed by enough arguments to make blockn blocks.
  • It shifts the positional parameters m times: the value of the m+1 variable becomes the value of the 1 variable, m+2 becomes 2 and so on, and # is set to n-m (floored at zero).
  • shift then execs into prog....

Notes

  • shift is a standard shell builtin. Be careful if you want to use it outside of an execline script.
  • The -b option is only useful to implement execline commands in the execline language. You shouldn't normally have to use it.