Re: Can $1 be set in a script?



On 2006-03-31, larryalk wrote:

It's easy to create
1=something
2=borrowed

You cannot set the positional parameters that way.

$ 1=something
bash: 1=something: command not found

echo $1 $2
something borrowed

Voila, $1 and $2 created where they didn't exist before.
But {1:-string} is even better.

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.



Relevant Pages

  • Re: USB neu starten
    ... PCI Interrupt Link enabled at IRQ 7 ... bash: SLPB: command not found ... bash: syntax error near unexpected token `supports' ... achim@achim:~$ ReiserFS: hdc5: found reiserfs format "3.6" with standard journal ...
    (de.comp.os.unix.linux.hardware)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.30)
    ... This is the Bash FAQ, version 3.30, for Bash version 3.0. ... Bash, the GNU Bourne-Again Shell. ... C3) Which new features in ksh-93 are not in bash, ... D1) Why does bash run a different version of `command' than ...
    (comp.unix.questions)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.30)
    ... This is the Bash FAQ, version 3.30, for Bash version 3.0. ... Bash, the GNU Bourne-Again Shell. ... C3) Which new features in ksh-93 are not in bash, ... D1) Why does bash run a different version of `command' than ...
    (comp.unix.questions)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.25)
    ... This is the Bash FAQ, version 3.25, for Bash version 2.05b. ... Bash, the GNU Bourne-Again Shell. ... C3) Which new features in ksh-93 are not in bash, ... D1) Why does bash run a different version of `command' than ...
    (comp.unix.questions)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.26)
    ... This is the Bash FAQ, version 3.26, for Bash version 2.05b. ... Bash, the GNU Bourne-Again Shell. ... C3) Which new features in ksh-93 are not in bash, ... D1) Why does bash run a different version of `command' than ...
    (comp.unix.questions)