Re:Build a Container Image from Scratch
by alkh on Thursday March 20, 2025 @10:12PM
(#43431175)
I am surprised that this is working, as I always thought that variables get initialized after the full command is parsed. So, I would assume that $_ would be related to the previous command (defined by a new line) and not this one, because there's no newline character here, but only an ampersand.
[ Parent
| on HN ]
&& means there's a sequence. So the second statement will only execute conditioned on the first sequence. So...
> thisFunctionFails && echo "Hello world" && echo "I SAID $_"
> thisFunctionSucceeds && echo "Hello world" && echo "I SAID $_"
Hello World
I SAID Hello World
The left function has to get evaluated before the next function. So it is still related to the previous command.