shell scripting

Shells, pipes and precedence

Shells, pipes and precedence

A fun distraction occurred this week when the following snippet of bash code was suggested in a pull request (simplified for demonstrative clarity): 1if [ echo $VAR1 | grep -q "text" ] || [ $VAR2 -eq 0 ]; then 2 echo "If test passed." 3else 4 echo "If test failed." 5fi Taken at initial face value, it looked like it should work okay. There didn’t appear to be anything immediately wrong with its syntax.