From 6f36a9e6494c723b209b253dfe3c83b62741c105 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 20 Aug 2016 13:45:17 +1200 Subject: Correctly bail from failed subshell --- sh/shrc.d/cd.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sh/shrc.d/cd.sh') diff --git a/sh/shrc.d/cd.sh b/sh/shrc.d/cd.sh index 37574f78..7bfacd6d 100644 --- a/sh/shrc.d/cd.sh +++ b/sh/shrc.d/cd.sh @@ -65,10 +65,10 @@ cd() { # Print the target printf '%s\n' "$new" + )" - # If the subshell failed, return from the function with the same exit - # value - )" || return + # If the subshell printed nothing, return with failure + [ -n "$2" ] || return fi # Execute the cd command as normal -- cgit v1.2.3