summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2022-05-17 14:08:09 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2022-05-17 14:08:09 +0000
commitbb2a3295cd7b5edf4ec7010d7a2cb42468875fd3 (patch)
tree1baa2cea60645e0175d5a486cdd08b849d6b9898
parentbd4ea95d8b3ce1258491e9fac7fcc37d2b241a16 (diff)
parentce4c99d8aa6e1c99e1c11778eed8b83838406797 (diff)
Merge branch 'no-which' into 'master'
scripts: Improve POSIX compatibility See merge request tartan/tartan!13
-rwxr-xr-xscripts/tartan24
-rwxr-xr-xscripts/tartan-build8
2 files changed, 16 insertions, 16 deletions
diff --git a/scripts/tartan b/scripts/tartan
index ba6cbcf..80c4940 100755
--- a/scripts/tartan
+++ b/scripts/tartan
@@ -1,6 +1,6 @@
#!/bin/bash
-clang_bin_dir=`dirname "$0"`
+clang_bin_dir=$(dirname "$0")
clang_prefix="$clang_bin_dir/.."
# Try and find the real Clang executable. $TARTAN_CC trumps everything.
@@ -13,8 +13,8 @@ elif [ "x$GNOME_CLANG_CC" != "x" ]; then
real_clang="$GNOME_CLANG_CC"
elif [ -f "$clang_prefix/bin/clang" ]; then
real_clang="$clang_prefix/bin/clang"
-elif [ -f `which clang` ]; then
- real_clang=`which clang`
+elif [ -f "$(command -v clang)" ]; then
+ real_clang=$(command -v clang)
else
echo "Error: Could not find clang executable. Set TARTAN_CC to the absolute path of the real clang executable." >& 2
exit 1
@@ -33,7 +33,7 @@ fi
# Vendor-specific clang version 3.6.2-1bo1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
# Target: x86_64-unknown-linux-gnu
# Thread model: posix
-clang_version=`"$real_clang" --version | head -n1 | sed -E 's/([^0-9]*)([0-9]*)\.([0-9]*)(\.[0-9]*)?(svn)?(.*)/\2.\3/'`
+clang_version=$("$real_clang" --version | head -n1 | sed -E 's/([^0-9]*)([0-9]*)\.([0-9]*)(\.[0-9]*)?(svn)?(.*)/\2.\3/')
# Sanity check.
if [ "$clang_version" == "" ]; then
@@ -161,26 +161,26 @@ if [ "$include_plugin_flags" = "1" ]; then
# Exec Clang with the plugin loaded.
if [ "$V" = "1" ]; then
echo "$real_clang" \
- ${argv[@]} \
- ${add_plugin[@]} \
- ${plugin_options[@]} \
+ "${argv[@]}" \
+ "${add_plugin[@]}" \
+ "${plugin_options[@]}" \
$GNOME_CLANG_CFLAGS \
$TARTAN_CFLAGS
fi
exec "$real_clang" \
- ${argv[@]} \
- ${add_plugin[@]} \
- ${plugin_options[@]} \
+ "${argv[@]}" \
+ "${add_plugin[@]}" \
+ "${plugin_options[@]}" \
$GNOME_CLANG_CFLAGS \
$TARTAN_CFLAGS
else
# Pass through to Clang with the arguments unchanged.
if [ "$V" = "1" ]; then
echo "$real_clang" \
- ${argv[@]}
+ "${argv[@]}"
fi
exec "$real_clang" \
- ${argv[@]}
+ "${argv[@]}"
fi
diff --git a/scripts/tartan-build b/scripts/tartan-build
index c6d5a40..dd469de 100755
--- a/scripts/tartan-build
+++ b/scripts/tartan-build
@@ -1,10 +1,10 @@
#!/bin/sh
-clang_bin_dir=`dirname "$0"`
+clang_bin_dir=$(dirname "$0")
-if which tartan &> /dev/null; then
- tartan=`which tartan`
-elif [ -x $clang_bin_dir/tartan ]; then
+if command -v tartan > /dev/null 2>&1; then
+ tartan=$(command -v tartan)
+elif [ -x "$clang_bin_dir/tartan" ]; then
tartan="$clang_bin_dir/tartan"
else
echo "Error: Could not find tartan script. Make sure Tartan is installed in your PATH." >& 2