diff options
author | Colin Watson <cjwatson@debian.org> | 2022-03-08 16:36:14 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2022-03-08 16:36:14 +0000 |
commit | be4e849ef3417fc2b976ad6019eab417c732ea2c (patch) | |
tree | afb8682801b61c2738d15c8b5bc4f6558c38f15e /tools | |
parent | d25829983629c590988e1d69f7b3ec9ce6b77531 (diff) |
Refactor use of cd in shell scripts
shellcheck warns about unchecked uses of `cd` (SC2164). Either check it
or refactor to avoid changing directory.
* src/tests/man-deleted-directory: Check `cd` call.
* src/tests/man-suffixed-extension: Avoid changing directory.
* tools/mkcatdirs: Likewise.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/mkcatdirs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/tools/mkcatdirs b/tools/mkcatdirs index bc5ccfaa..d470d36f 100755 --- a/tools/mkcatdirs +++ b/tools/mkcatdirs @@ -23,7 +23,6 @@ #PATH=.:/usr/local/bin:/usr/bin:/bin progname=$(basename "$0") -here=$(pwd) test_only= # sort out the command line options @@ -67,12 +66,11 @@ do [ -d "$manpath" ] || continue echo "Manual page hierarchy: $manpath" catdir=$(MANPATH=$manpath manpath -qc 2>/dev/null) - cd "$manpath" subdirs= - for subdir in $(echo man?*) + for subdir in $(cd "$manpath" && echo man?*) do - test -d "$subdir" && + test -d "$manpath/$subdir" && subdirs="$subdirs $(echo "$subdir" | sed -e 's,man,cat,')" done @@ -85,8 +83,7 @@ do subs_ok= for subdir in $subdirs do - cd "$catdir" - test -d "$subdir" && + test -d "$catdir/$subdir" && subs_ok="$subs_ok $subdir" || subs_needed="$subs_needed $subdir" done @@ -104,7 +101,6 @@ do catdirs= fi - cd "$here" if test "$test_only" = "no" && test "$catdirs" then echo " " |