Hi,

I stumbled about another bash problem today:

for item in $(false);
  echo $item
done || { echo for failed; }

doesn't fail. I think it's bad that there is no
  set -e 

like switch which really catches all failures of this kind.

If you want to ignore non zero exit status you can always use || true.

Of course the workaround is obvious: use

  dummy_var=$(false)
  for item in $dummy_var;
    echo $item
  done || { echo for failed; }

However you have to remeber this pitfall.

I know that some scripts may depend on the current behaviour.
So what about adding a new switch beeing more strict?

Sincerly
Marc Weber


Reply via email to