From fc73cee156b16c7b8b62594ad10103d3496b5cfe Mon Sep 17 00:00:00 2001 From: SkyLined Date: Mon, 8 Jul 2024 10:01:34 +0200 Subject: [PATCH] Fix risk of popd without a pushd `pushd` was inside if, `popd` was outside; there was a risk of not doing a `pushd` and only doing a `popd`. Signed-off-by: SkyLined --- automated install/basic-install.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6b65313e..752e9816 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -378,14 +378,13 @@ is_repo() { pushd "${directory}" &>/dev/null || return 1 # Use git to check if the directory is a repo # git -C is not used here to support git versions older than 1.8.4 - git status --short &>/dev/null || rc=$? - # If the command was not successful, + git status --short &> /dev/null || rc=$? + # Move back into the directory the user started in + popd &> /dev/null || return 1 else # Set a non-zero return code if directory does not exist rc=1 fi - # Move back into the directory the user started in - popd &>/dev/null || return 1 # Return the code; if one is not set, return 0 return "${rc:-0}" }