blob: ed9a1d4dbd4905df590984578a82cf3581e09af7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/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
|