Skip to contentSkip to conversation

Remove bashisms from scripts

PATCH In review dann frazier 2 participants 2 messages May 23, 2009 – May 24, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove bashisms from scripts

The '-e' option to echo and brace expansion are not guaranteed to be supported by a POSIX-compliant /bin/sh (e.g. dash)

---
 scripts/gcc-version.sh |    2 +-
 scripts/ver_linux      |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
scripts/gcc-version.sh +1 -1
index cc767b3..debecb5 100644
@@ -18,7 +18,7 @@ compiler="$*"
 
 if [ ${#compiler} -eq 0 ]; then
 	echo "Error: No compiler specified."
-	echo -e "Usage:\n\t$0 <gcc-command>"
+	printf "Usage:\n\t$0 <gcc-command>\n"
 	exit 1
 fi
 
scripts/ver_linux +1 -1
index dbb3037..7de36df 100755
@@ -65,7 +65,7 @@ sed -n -e '/^.*\/libc-\([^/]*\)\.so$/{s//\1/;p;q}' < /proc/self/maps
 ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \
 'NR==1{print "Dynamic linker (ldd)  ", $NF}'
 
-ls -l /usr/lib/lib{g,stdc}++.so  2>/dev/null | awk -F. \
+ls -l /usr/lib/libg++.so /usr/lib/libstdc++.so  2>/dev/null | awk -F. \
        '{print "Linux C++ Library      " $4"."$5"."$6}'
 
 ps --version 2>&1 | grep version | awk \
Signature · 1 line
1.6.3.1
#1 lore raw

scripts/gcc-version.sh compiler="$*" · line 21

Quoted 1 line · dann frazier
scripts/gcc-version.sh +1 -0
+	printf "Usage:\n\t$0 <gcc-command>\n"

Don't put variable text in the format string, its expansion may contain % characters, causing spurious errors.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."