Can anyone explain this behavior? Running:
#!/bin/sh
echo \"hello world\" | read var1 var2
echo $var1
echo $var2
results in nothing being o
A recent addition to bash is the lastpipe option, which allows the last command in a pipeline to run in the current shell, not a subshell, when job control is deactivated.
#!/bin/bash
set +m # Deactiveate job control
shopt -s lastpipe
echo "hello world" | read var1 var2
echo $var1
echo $var2
will indeed output
hello
world