[opensuse] Re: umm BASH gurus, what does the typo $!/bin/bash do?



John Andersen wrote:
David C. Rankin wrote:

Can anybody tell me, or point me to any info, concerning just what $! did??

So it was probably trying to figure out what $ meant.
Then it saw the !.

When you type a word preceeded by an "!", bash thinks you want to recall a previous command
or "event". It happens in interactive shells, when the C-Shell-styled history expansion
(”!searchword”) is enabled. This is the default.

Ahem, no. $! is a standard bash variable. From the bash manual:


3.4.2 Special Parameters
------------------------

The shell treats several parameters specially. These parameters
may only be referenced; assignment to them is not allowed.
[...]

`!'
Expands to the process ID of the most recently executed
background (asynchronous) command.

Since there has not been any background process in this subshell,
it expands to the empty string.

Joachim

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim Schrod Email: jschrod@xxxxxxx
Roedermark, Germany

--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx



Relevant Pages

  • Re: The meaning of $$.
    ... would you normally execute it as a command to ... the man page for bash. ... The shell treats several parameters specially. ... $ Expands to the process ID of the shell. ...
    (comp.unix.shell)
  • 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.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.shell)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.24)
    ... This is the Bash FAQ, version 3.24, 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.shell)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.24)
    ... This is the Bash FAQ, version 3.24, 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.shell)