diff options
author | Akira Yokosawa <akiyks@gmail.com> | 2023-03-05 20:47:06 +0900 |
---|---|---|
committer | Akira Yokosawa <akiyks@gmail.com> | 2023-03-10 22:48:50 +0900 |
commit | fbcd7ed25527e9c89196b0155678d6bcee47d58a (patch) | |
tree | 06b062ed99b222761e2b3e308a441071048bae71 /utilities | |
parent | 77d9fbc8be428306bfc6d74d57ec8d5c538e5d04 (diff) | |
download | perfbook-fbcd7ed25527e9c89196b0155678d6bcee47d58a.tar.gz |
Stop using 'which' command in build scripts
These days, it becomes normal where "which" command is not found
in minimal container images such as fedora and archlinux.
Since POSIX 2008, a portable and efficient way of testing command
availability is:
command -v <command_name>
Use it in build scripts (via make and shell variable WHICH) instead.
Link: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Diffstat (limited to 'utilities')
-rwxr-xr-x | utilities/cleverefcheck.sh | 3 | ||||
-rw-r--r-- | utilities/mpostcheck.sh | 4 | ||||
-rwxr-xr-x | utilities/precheck.sh | 5 |
3 files changed, 8 insertions, 4 deletions
diff --git a/utilities/cleverefcheck.sh b/utilities/cleverefcheck.sh index 546c64ef..ba2eabb4 100755 --- a/utilities/cleverefcheck.sh +++ b/utilities/cleverefcheck.sh @@ -1,6 +1,7 @@ #!/bin/sh : ${GREP:=grep} +: ${WHICH:=command -v} CREFPTN='\\[Cc](ln)?ref[{][^}]+}\s*[{][^}]+}' tex_sources_all=`find . -name "*.tex" -print` @@ -41,6 +42,6 @@ do fi done if [ $grep_z_opt -eq 0 ] ; then - echo "`which $GREP` doesn't know the -z option." + echo "`$WHICH $GREP` doesn't know the -z option." echo "Skipping \\crefrange checks." fi diff --git a/utilities/mpostcheck.sh b/utilities/mpostcheck.sh index c3934559..9d4b939e 100644 --- a/utilities/mpostcheck.sh +++ b/utilities/mpostcheck.sh @@ -111,6 +111,8 @@ # follow the instruction given there. #------------------------------------------------------------------- +: ${WHICH:=command -v} + dogrep() { texsrc=`find . -name "*.tex" -print` bibsrc=`find . -name "*.bib" -print` @@ -130,7 +132,7 @@ dogrep() { fi } -if which kpsewhich >/dev/null +if $WHICH kpsewhich >/dev/null then command_list_orig=`kpsewhich -var-value=shell_escape_commands` command_list=`echo $command_list_orig | sed -E "s/r-u?p?mpost,//g"` diff --git a/utilities/precheck.sh b/utilities/precheck.sh index 1e844d81..4d5c31a1 100755 --- a/utilities/precheck.sh +++ b/utilities/precheck.sh @@ -11,6 +11,7 @@ LC_TIME=C : ${SED:=sed} : ${DATE:=date} : ${VERBOSE:=} +: ${WHICH:=command -v} fatal="" @@ -68,7 +69,7 @@ if [ "$sed_result" != "OK" -o "$VERBOSE" != "" ] ; then if [ "$sed_result" = "OK" ] ; then echo "OK." else - echo "$SED (at `which $SED`) failed the test!" + echo "$SED (at `$WHICH $SED`) failed the test!" fi fi if [ "$date_result" != "OK" -o "$VERBOSE" != "" ] ; then @@ -79,7 +80,7 @@ if [ "$date_result" != "OK" -o "$VERBOSE" != "" ] ; then echo -n "$date_flavor ... " if [ "$date_flavor" = "Unknown" ] ; then echo - echo "Unknown date command found at `which $DATE`." + echo "Unknown date command found at `$WHICH $DATE`." else if [ "$month" = "January" ] ; then echo "OK." |