[Most of this article, except IFS and
--, also applies to the
C shell. -JP]
The Bourne shell command line can have options like -e (exit if any command returns non-zero status). It can also have other arguments; these are passed to shell scripts. You can set new command-line parameters while you're typing interactive commands (at a shell prompt) or in a shell script.
mail $group1 < messagemail andy ellen heather steve wilma < message $
mail $group2 < messagemail firstname.lastname@example.org email@example.com firstname.lastname@example.org < message $
set +v cancels the v option on many Bourne shells.
You can put filenames or any other strings in the command-line parameters
interactively or from a shell script.
That's handy for storing and parsing the output of a UNIX command with
$2, and so on.
if your system has it.
to strip off everything but the
something new...use new settings... set $oldparms
If the first parameter you set starts with a dash, like
the shell will treat it as its own option instead of as a string to
put into the command-line parameters.
To avoid this, use
-- (two dashes) as the first argument to
In this example,
$1 gets -e, and the filenames expanded
from the wildcard pattern go into
set -- -e file*
Because the shell parses and scans the new parameters before it stores them, and other will be interpreted - watch your . You can take advantage of this to parse lines of text into pieces that aren't separated with the usual spaces and TABs - for instance, a line from a database with colon-separated fields - by setting the variable before the set command.
If you want to save any special quoting on the original command line,
be careful; the quoting will be lost unless you're clever.
For example, if
$1 used to be John Smith,
it'll be split
after it's restored:
$1 will have John and
$2 will be
solution might be to use a
for the part of the script where you need to reset the command-line
# reset command-line parameters during subshell only: (set
some new parameters...do something with new parameters... ) # original parameters aren't affected from here on...
One last note: set won't set
$0, the name of the script file.