Skip to content

Commit e95e558

Browse files
committed
Improved bootstrap run script.
Improved command exit status handling. Signed-off-by: kilo52 <[email protected]>
1 parent fb3301d commit e95e558

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

bootstrap/run.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function bootstrap_project_init() {
106106
if [[ "${cache_dirs[0]}" == "$cache_dir_pattern" ]]; then
107107
# No cache dir found, so create one
108108
base_res_dir="$(mktemp -d pi_cache_${_EUID}_XXXXXXXXXX)";
109-
cmd_exit_status=$?;
109+
local cmd_exit_status=$?;
110110
if (( cmd_exit_status != 0 )); then
111111
echo "ERROR: Command 'mktemp' returned non-zero exit status ${cmd_exit_status}";
112112
echo "ERROR: Failed to create Project Init resource cache" \
@@ -215,14 +215,10 @@ function main() {
215215
echo "Please make sure that mktemp is correctly installed.";
216216
return 1;
217217
fi
218-
local cmd_exit_status=0;
219218
# Save the CWD and restore it before starting initmain
220219
local _USER_CWD="$PWD";
221-
cd "$PROJECT_INIT_CACHE_LOCATION";
222-
cmd_exit_status=$?;
223-
if (( cmd_exit_status != 0 )); then
224-
echo "ERROR: Failed to change active working directory" \
225-
"to $PROJECT_INIT_CACHE_LOCATION";
220+
if ! cd "$PROJECT_INIT_CACHE_LOCATION"; then
221+
echo "ERROR: Failed to change active working directory to ${PROJECT_INIT_CACHE_LOCATION}";
226222
return 1;
227223
fi
228224
if [[ $arg_no_cache == true ]]; then

0 commit comments

Comments
 (0)