2010-05-06 21:08:04 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2007-03-09 09:33:34 +01:00
|
|
|
SEDLIST="/usr/bin/sed /bin/sed sed gnused gsed"
|
|
|
|
|
|
|
|
for SED in $SEDLIST
|
|
|
|
do
|
|
|
|
if ! test -x $SED ; then
|
2007-05-11 14:50:15 +02:00
|
|
|
SED=$(which $SED 2> /dev/null)
|
2007-03-09 09:33:34 +01:00
|
|
|
if ! test -x "$SED" > /dev/null ; then
|
|
|
|
SED=""
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-06-21 22:33:51 +02:00
|
|
|
tmp=$(mktemp)
|
|
|
|
echo "HELLO" > $tmp
|
|
|
|
$SED -i -e "s/HELLO/GOODBYE/" $tmp >/dev/null 2>&1
|
|
|
|
RESULT=$(cat $tmp)
|
2007-03-09 09:33:34 +01:00
|
|
|
|
|
|
|
if test $? != 0 ; then
|
|
|
|
SED=""
|
|
|
|
elif test -e ".sedtest-e" ; then
|
|
|
|
rm -f ".sedtest-e"
|
|
|
|
SED=""
|
2007-03-12 09:55:20 +01:00
|
|
|
elif [ "x$RESULT" = "x" ] || [ "$RESULT" != "GOODBYE" ] > /dev/null ;
|
2007-03-10 11:29:08 +01:00
|
|
|
then
|
2007-03-09 09:33:34 +01:00
|
|
|
SED=""
|
|
|
|
fi
|
|
|
|
|
2010-06-21 22:33:51 +02:00
|
|
|
rm -f $tmp
|
2007-03-09 09:33:34 +01:00
|
|
|
if [ ! -z "$SED" ] ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo $SED
|