kumquat-buildroot/toolchain/dependencies/check-host-sed.sh
Peter Korsgaard bec3480a44 check-host-sed.sh: use mktemp for temporary file
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
2010-06-21 23:02:31 +02:00

36 lines
578 B
Bash
Executable File

#!/bin/sh
SEDLIST="/usr/bin/sed /bin/sed sed gnused gsed"
for SED in $SEDLIST
do
if ! test -x $SED ; then
SED=$(which $SED 2> /dev/null)
if ! test -x "$SED" > /dev/null ; then
SED=""
continue
fi
fi
tmp=$(mktemp)
echo "HELLO" > $tmp
$SED -i -e "s/HELLO/GOODBYE/" $tmp >/dev/null 2>&1
RESULT=$(cat $tmp)
if test $? != 0 ; then
SED=""
elif test -e ".sedtest-e" ; then
rm -f ".sedtest-e"
SED=""
elif [ "x$RESULT" = "x" ] || [ "$RESULT" != "GOODBYE" ] > /dev/null ;
then
SED=""
fi
rm -f $tmp
if [ ! -z "$SED" ] ; then
break
fi
done
echo $SED