Date:        Thu, 11 Sep 2025 16:23:18 -0400
    From:        Ken Hornstein <[email protected]>
    Message-ID:  <[email protected]>

  | That's one of those corner cases I wasn't quite aware of
  | the rules of; like I said, I didn't test that.

A simple test is (the first 3 lines of):

$SHELL -c 'printf "Start with %s\n" "$$"
( printf "In subshell: %s\n" "$$" )
printf "In cmdsub: %s\n" "$( printf "%s" "$$" )"'
Start with 7726
In subshell: 7726
In cmdsub: 7726

(the actual PID (value of $$) in the output will obviously vary).
(And no, it isn't really usually important to quote $$ - but in
general, unless there is a compelling reason not to, all shell
expansions should be quoted - just forms good habits).

This will work with SHELL set to any Bourne equiv shell you
can find, and even with csh/tcsh; though for those the command
substitution can't remain as written (might not even exist in
simple csh, it has been too long since I used it) and might be
pointless testing anyway (as in, expansions in it might happen
in the context of the parent shell - I no longer care about csh).

kre

ps: if your current shell (to be used to run that command) is a csh
variety, then the multi-line string is likely to be a problem I think,
either combine the 3 lines together, just stick a ';' in place of the
two newlines, or put this in a script to be run by some (any) real shell
variant, or just temporarily invoke a Bourne shell (any) to run this
command.

Reply via email to