How can I set a one-shot variable that affects an entire compound command?
E.g., something like:
FOO=1 ./foo.sh && ./foo.sh
where foo.sh
contains echo "FOO=$FOO"
will print:
FOO=1
FOO=
I would like the value of FOO
to be set for entire pipeline (but I don't want to set or export it in my current shell). A subshell works:
( export FOO=1; ./foo.sh && ./foo.sh )
... but is there a way w/o a subshell?
FOO=1 ./foo.sh && FOO=1 ./foo.sh
is unacceptable?FOO
to change it in all of them. The subshell works OK I guess, just wondering if there was a syntax I was missing.