1997-08-28 02:21:56 +08:00
|
|
|
#! /bin/sh
|
|
|
|
# quote.test - make sure that shell metacharacters do not blow up libtool
|
|
|
|
|
|
|
|
# Test script header.
|
|
|
|
need_prefix=no
|
|
|
|
if test -z "$srcdir"; then
|
|
|
|
srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
|
|
|
|
test "$srcdir" = "$0" && srcdir=.
|
|
|
|
test "${VERBOSE+set}" != "set" && VERBOSE=yes
|
|
|
|
fi
|
|
|
|
. $srcdir/defs || exit 1
|
|
|
|
|
|
|
|
# Do the torture test.
|
|
|
|
status=0
|
|
|
|
|
1997-08-29 11:09:18 +08:00
|
|
|
echo=echo
|
1998-04-15 00:29:20 +08:00
|
|
|
if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then :
|
1997-08-29 11:09:18 +08:00
|
|
|
else
|
1998-04-20 03:29:28 +08:00
|
|
|
# The Solaris, AIX, and Digital Unix default echo programs unquote
|
1998-04-15 00:29:20 +08:00
|
|
|
# backslashes. This makes it impossible to quote backslashes using
|
1997-08-29 11:09:18 +08:00
|
|
|
# echo "$something" | sed 's/\\/\\\\/g'
|
1998-04-15 00:29:20 +08:00
|
|
|
#
|
1998-04-20 03:29:28 +08:00
|
|
|
# So, first we look for a working echo in the user's PATH.
|
1998-04-15 00:29:20 +08:00
|
|
|
IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
|
|
|
|
for dir in $PATH /usr/ucb; do
|
|
|
|
if test -f $dir/echo && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t'; then
|
|
|
|
echo="$dir/echo"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="$save_ifs"
|
|
|
|
|
|
|
|
if test "X$echo" = Xecho; then
|
1998-04-20 03:29:28 +08:00
|
|
|
# We didn't find a better echo, so look for alternatives.
|
|
|
|
if test "X`(print -r '\t') 2>/dev/null`" = 'X\t'; then
|
|
|
|
# This shell has a builtin print -r that does the trick.
|
|
|
|
echo='print -r'
|
|
|
|
elif test -f /bin/ksh && test "X$CONFIG_SHELL" != X/bin/ksh; then
|
|
|
|
# If we have ksh, try running ltconfig again with it.
|
|
|
|
CONFIG_SHELL=/bin/ksh
|
|
|
|
export CONFIG_SHELL
|
|
|
|
exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"}
|
1998-04-15 00:29:20 +08:00
|
|
|
else
|
1998-04-20 03:29:28 +08:00
|
|
|
# Try using printf.
|
|
|
|
echo='printf %s\n'
|
|
|
|
if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then :
|
|
|
|
else
|
|
|
|
# Oops. We lost completely, so just stick with echo.
|
|
|
|
echo=echo
|
|
|
|
fi
|
1998-04-15 00:29:20 +08:00
|
|
|
fi
|
1997-08-29 11:09:18 +08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
1997-08-28 02:21:56 +08:00
|
|
|
for mode in compile link install; do
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "== $mode mode"
|
1997-08-28 02:21:56 +08:00
|
|
|
|
|
|
|
# Unfortunately, without an array data type, it is nearly impossible
|
|
|
|
# to protect libtool from metacharacters in filenames. So, we just
|
|
|
|
# try metacharacters in the options it needs to pass to other programs.
|
|
|
|
|
|
|
|
# preargs and postargs need to go through libtool unmodified.
|
|
|
|
case "$mode" in
|
|
|
|
compile)
|
|
|
|
preargs="gcc -c"
|
1999-12-18 15:50:04 +08:00
|
|
|
preflag=
|
1997-08-28 02:21:56 +08:00
|
|
|
flag="-DVAR="
|
|
|
|
postargs="foo.c"
|
|
|
|
;;
|
|
|
|
|
|
|
|
link)
|
|
|
|
preargs="gcc -o hell -g -O"
|
1999-12-18 15:50:04 +08:00
|
|
|
preflag=-Wl,
|
|
|
|
flag="-someflag="
|
1997-08-28 02:21:56 +08:00
|
|
|
postargs="foo.o"
|
|
|
|
;;
|
|
|
|
|
|
|
|
install)
|
|
|
|
preargs="install -c"
|
1999-12-18 15:50:04 +08:00
|
|
|
preflag=
|
1997-08-28 02:21:56 +08:00
|
|
|
flag="--something="
|
|
|
|
postargs="hell /usr/local/bin/hell"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Trivial.
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "= trying: no quoting"
|
1999-12-18 15:50:04 +08:00
|
|
|
result=`$libtool -n --mode=$mode $preargs ${preflag}"${flag}test" $postargs` || status=1
|
1997-08-28 02:21:56 +08:00
|
|
|
case "$result" in
|
1999-12-18 15:50:04 +08:00
|
|
|
*"$preargs ${preflag}${flag}test "*)
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "= passed: $result"
|
1997-08-28 02:21:56 +08:00
|
|
|
;;
|
|
|
|
*)
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "= failed: $result"
|
1997-08-28 02:21:56 +08:00
|
|
|
status=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Metacharacters that should be backslashified.
|
1997-11-15 02:04:44 +08:00
|
|
|
for mchar in \\ \" \` \$; do
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "= trying: \\$mchar quoting"
|
1999-12-18 15:50:04 +08:00
|
|
|
result=`$libtool -n --mode=$mode $preargs ${preflag}"${flag}${mchar}test${mchar}" $postargs` || status=1
|
1997-08-28 02:21:56 +08:00
|
|
|
case "$result" in
|
1999-12-18 15:50:04 +08:00
|
|
|
*"$preargs ${preflag}${flag}\\${mchar}test\\${mchar} "*)
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "= passed: $result"
|
1997-08-28 02:21:56 +08:00
|
|
|
;;
|
|
|
|
*)
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "= failed: $result"
|
1997-08-28 02:21:56 +08:00
|
|
|
status=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Metacharacters that should be double quoted.
|
|
|
|
for mchar in "[" "]" "~" "#" "^" "&" "*" "(" ")" "{" "}" "|" ";" "<" ">" "?" \
|
|
|
|
"'" " " " "; do
|
|
|
|
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "= trying: \"$mchar\" quoting"
|
1999-12-18 15:50:04 +08:00
|
|
|
result=`$libtool -n --mode=$mode $preargs ${preflag}"${flag}${mchar}test${mchar}" $postargs` || status=1
|
1997-08-28 02:21:56 +08:00
|
|
|
case "$result" in
|
1999-12-18 15:50:04 +08:00
|
|
|
*"$preargs ${preflag}\"${flag}${mchar}test${mchar}\" "*)
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "= passed: $result"
|
1997-08-28 02:21:56 +08:00
|
|
|
;;
|
|
|
|
*)
|
1997-08-29 11:09:18 +08:00
|
|
|
$echo "= failed: $result"
|
1997-08-28 02:21:56 +08:00
|
|
|
status=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
exit $status
|