summaryrefslogtreecommitdiff
path: root/usr.bin/ctfconv
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2017-08-12 19:51:18 +0000
committerJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2017-08-12 19:51:18 +0000
commit0988de2a87fa15a2f8b7786566410728fefdbaf8 (patch)
treed027b0f7ffeb49ee21e889e2efe51033a554317c /usr.bin/ctfconv
parentf9ff0bc8d88f9f3a412218f30109fdf321feed46 (diff)
make this properly portable:
- keep track of the argument inside the for loop to determine INFILE - replace the builtin [[ with [ and adjust the tests - use echo instead of the print builtin from tb@
Diffstat (limited to 'usr.bin/ctfconv')
-rwxr-xr-xusr.bin/ctfconv/ctfstrip12
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/ctfconv/ctfstrip b/usr.bin/ctfconv/ctfstrip
index ebb7cbbbdd4..945286a996e 100755
--- a/usr.bin/ctfconv/ctfstrip
+++ b/usr.bin/ctfconv/ctfstrip
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $OpenBSD: ctfstrip,v 1.4 2017/08/12 16:33:11 jasper Exp $
+# $OpenBSD: ctfstrip,v 1.5 2017/08/12 19:51:17 jasper Exp $
#
# Copyright (c) 2017 Martin Pieuchot
#
@@ -40,19 +40,19 @@ for arg in "$@"; do
esac
shift
set -- "$@" "$arg"
+ INFILE="$arg"
done
-if [[ $# == 0 ]]; then
- print -u2 "${USAGE}";
+if [ $# -eq 0 ]; then
+ echo "${USAGE}" >&2
exit 1
fi
LABEL="unknown"
TMPFILE=$(mktemp /tmp/.ctf.XXXXXXXXXX)
-INFILE=$(eval "echo \${$#}")
# Extract kernel version
-if [[ "$INFILE" == bsd* ]]; then
+if [ -z "${INFILE##bsd*}" ]; then
LABEL=`what $INFILE |tr -d '\n'|awk -F"${INFILE} " '{ print $2 '\n' }'`
fi
@@ -60,7 +60,7 @@ fi
# So try to run ctfconv and silently fallback to plain strip(1) if that failed.
ctfconv -o ${TMPFILE} -l "${LABEL}" ${INFILE} 2> /dev/null
-if [[ $? == 0 ]]; then
+if [ $? -eq 0 ]; then
objcopy --add-section .SUNW_ctf=${TMPFILE} ${STRIPFLAG} ${INFILE} ${OUTFILE}
else
strip ${STRIPFLAG} $@ -o ${OUTFILE} ${INFILE}