6 Note added.
source | link

If there's a specific line to be made conditionally immune to set -e, this works:

false || true

This can be shortened to:

false || :

Or most cryptically:

false||:

If there's several lines, surround them in curly braces:

{ false; false; } || true

Note that false here represents a stand-in for any code that might return an error code. Of course false prints no output; but something like ls /bin/bash /bin/bbbbbbbash would print to STDOUT and STDERR, and using the above method it still would.

Or surround the code to be made immune with set statements:

set +e; false ; set -e

Note: the above methods work whether the lines in question return an error code or are successful. If it's known that a specific line is certain to return an error, all that's needed is a leading !:

! false

If there's a specific line to be made immune to set -e, this works:

false || true

This can be shortened to:

false || :

Or most cryptically:

false||:

If there's several lines, surround them in curly braces:

{ false; false; } || true

Note that false here represents a stand-in for any code that might return an error code. Of course false prints no output; but something like ls /bin/bash /bin/bbbbbbbash would print to STDOUT and STDERR, and using the above method it still would.

Or surround the code to be made immune with set statements:

set +e; false ; set -e

If there's a specific line to be made conditionally immune to set -e, this works:

false || true

This can be shortened to:

false || :

Or most cryptically:

false||:

If there's several lines, surround them in curly braces:

{ false; false; } || true

Note that false here represents a stand-in for any code that might return an error code. Of course false prints no output; but something like ls /bin/bash /bin/bbbbbbbash would print to STDOUT and STDERR, and using the above method it still would.

Or surround the code to be made immune with set statements:

set +e; false ; set -e

Note: the above methods work whether the lines in question return an error code or are successful. If it's known that a specific line is certain to return an error, all that's needed is a leading !:

! false
5 Shortened code.
source | link

If there's a specific line to be made immune to set -e, this works:

false || true

This can be shortened to:

false || :

Or most cryptically:

false||:

If there's several lines, surround them in curly braces:

{ false; false; } || true

Note that false here represents a stand-in for any code that might return an error code. Of course false prints no output; but something like ls /bin/bash /bin/bbbbbbbash would print to STDOUT and STDERR, and using the above method it still would.

Or surround the code to be made immune with set statements:

set +e; false ; set -e

If there's a specific line to be made immune to set -e, this works:

false || true

If there's several lines, surround them in curly braces:

{ false; false; } || true

Note that false here represents a stand-in for any code that might return an error code. Of course false prints no output; but something like ls /bin/bash /bin/bbbbbbbash would print to STDOUT and STDERR, and using the above method it still would.

Or surround the code to be made immune with set statements:

set +e; false ; set -e

If there's a specific line to be made immune to set -e, this works:

false || true

This can be shortened to:

false || :

Or most cryptically:

false||:

If there's several lines, surround them in curly braces:

{ false; false; } || true

Note that false here represents a stand-in for any code that might return an error code. Of course false prints no output; but something like ls /bin/bash /bin/bbbbbbbash would print to STDOUT and STDERR, and using the above method it still would.

Or surround the code to be made immune with set statements:

set +e; false ; set -e
4 Tweak.
source | link

If there's a specific line to be made immune to set -e, this works:

false || true

If there's several lines, surround them in curly braces:

{ false; false; } || true

Note that false here represents a stand-in for any code that might return an error code. Of course false prints no output; but something like ls /bin/bash /bin/bbbbbbbash would print to STDOUT and STDERR, and it still would using the above method it still would.

Or surround the code to be made immune with set statements:

set +e; false ; set -e

If there's a specific line to be made immune to set -e, this works:

false || true

If there's several lines, surround them in curly braces:

{ false; false; } || true

Note that false here represents a stand-in for any code that might return an error code. Of course false prints no output; but something like ls /bin/bash /bin/bbbbbbbash would print to STDOUT and STDERR, and it still would using the above method.

Or surround the code to be made immune with set statements:

set +e; false ; set -e

If there's a specific line to be made immune to set -e, this works:

false || true

If there's several lines, surround them in curly braces:

{ false; false; } || true

Note that false here represents a stand-in for any code that might return an error code. Of course false prints no output; but something like ls /bin/bash /bin/bbbbbbbash would print to STDOUT and STDERR, and using the above method it still would.

Or surround the code to be made immune with set statements:

set +e; false ; set -e
3 Better method.
source | link
2 Fixed code stupidity, improved text.
source | link
1
source | link