unbash awesome-client

-e and -p options for read are bashizm, so awesome-client don't work
if /bin/sh is something other than bash (for example it fails with
pdksh which is default shell on PLD Linux).

The simplest sollution is 's,#!/bin/sh,#!/bin/bash,'. But I believe
that it is better to patch script so it will work with any POSIX
compliant shell.

Attached patch checks if shell is bash. If no it disables use of
non-standard read options.

I've also changed `` to $(), as backquotes are obsolete and
shouldn't be used.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Paweł Zuzelski 2009-06-12 09:14:29 +02:00 committed by Julien Danjou
parent b7f05f32c0
commit 1fe239e577
1 changed files with 12 additions and 3 deletions

View File

@ -1,7 +1,8 @@
#!/bin/sh
# rlwrap provides readline to stuff which doesn't know readline by itself
RLWRAP=`which rlwrap 2>/dev/null`
RLWRAP=$(which rlwrap 2>/dev/null)
READ_OPTIONS="-r"
if [ "$RLWRAP" != "" ]
then
@ -10,7 +11,15 @@ then
A_RERUN="no" exec $RLWRAP $0
fi
else
USE_READLINE="-e"
if [ "$BASH" ]
then
READ_PARAMETERS=" -e"
fi
fi
if [ $BASH ]
then
READ_OPTIONS="$READ_OPTIONS -p awesome# "
fi
DBUS_SEND=dbus-send
@ -32,7 +41,7 @@ a_dbus_send()
$DBUS_METHOD string:"$1" | tail -n +2
}
while read ${USE_READLINE} -r -p "awesome# " line
while read ${USE_READLINE} ${READ_OPTIONS} line
do
a_dbus_send "$line"
done