From 7f319862af5e165e2daffc43c439ba9df97c75fc Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sat, 17 Aug 2019 12:49:17 +0300 Subject: [PATCH] add abort with custom error message --- SC2164.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SC2164.md b/SC2164.md index 8db6138..85c64ef 100644 --- a/SC2164.md +++ b/SC2164.md @@ -35,7 +35,8 @@ If/when it does, the script will keep going and do all its operations in the wro To avoid this, make sure you handle the cases when `cd` fails. Ways to do this include -* `cd foo || exit` as suggested to just abort immediately +* `cd foo || exit` as suggested to abort immediately, reusing exit code from failed `cd` command +* `cd foo || { echo "Failure"; exit 1; }` abort with custom message * `if cd foo; then echo "Ok"; else echo "Fail"; fi` for custom handling * `<(cd foo && cmd)` as an alternative to `<(cd foo || exit; cmd)` in `<(..)`, `$(..)` or `( )`