Benjamin Schieder

[TECH] BREAKING OUT OF IF-BLOCKS IN BASH

2011 March 11

Today I wanted to break out of an if-block in bash.

Neither the break nor the continue works mean anything in an if-block, so what to do? Create a subprocess (if your code allows it):

if [ -n "${PS1}" ] ; then
(
[ -w / ] && exit
...
)
fi



EOF

Category: blog

Tags: Tech bash