I think our documentation on $! is a little misleading. `man bash' states:

    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.

I don't think this statement is true. Take this as an example:

    $ sleep 60
    ^Z
    [1]+  Stopped                 sleep 60
    $ sleep 60 &
    [2] 6580
    $ bg
    [1]+ sleep 60 &
    $ echo "$!"
    6579

The pipeline with the PID referenced by $! was not executed last, it was merely
backgrounded last. I suggest s/executed background/backgrounded/.

If this is accepted as valid, I will happily write and attach a patch.

Best,

Chris

Attachment: pgpUkRpRHbYxG.pgp
Description: PGP signature

Reply via email to