Fix risk of popd without a pushd (#5701)

This commit is contained in:
yubiuser 2024-09-04 21:46:21 +02:00 committed by GitHub
commit 915352aefb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -379,13 +379,12 @@ is_repo() {
# 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,
# 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}"
}