SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

cd can fail for a variety of reasons: misspelled paths, missing
directories, missing permissions, broken symlinks and more.

If/when it does, the script will keep going and do all its operations in
the wrong directory. This can be messy, especially if the operations
involve creating or deleting a lot of files.

PR:		227109
Submitted by:	mat
Sponsored by:	Absolight
This commit is contained in:
Mathieu Arnold 2018-06-01 16:20:48 +00:00
parent 2364943f9d
commit ccbfedd88c
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=471272

View file

@ -920,7 +920,7 @@ checks="$checks suidfiles libtool libperl prefixvar baselibs terminfo"
checks="$checks proxydeps sonames perlcore no_arch gemdeps gemfiledeps flavors"
ret=0
cd ${STAGEDIR}
cd ${STAGEDIR} || exit 1
for check in ${checks}; do
${check} || ret=1
done