5

I have an unusual problem with -e flag in a following bash script:

#!/bin/bash -e
foo() { return 1; }
bar() { foo; bar; }
bar || exit 1

Namely the script does not terminate, even though the foo function returns 1. However after removing '|| exit 1' part this script works as expected- it fails just after the first foo execution.

#!/bin/bash -e
foo() { return 1; }
bar() { foo; bar; }
bar

EDIT: bash versions tested: GNU bash, version 4.1.2(2)-release (x86_64-redhat-linux-gnu) GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)

padura
  • 123

0 Answers0