awesome-client: Handle errors when running arguments

Commit 78abb4a54c made awesome-client fail with a
non-zero exit code when sending a command that it got from stdin failed.

Commit f0f31bc305 added the possibility to specify
commands to run as arguments to awesome-client. However, the exit code was still
zero even when such a command failed.

This commit makes awesome-client signal errors with its exit code even for code
specified via arguments.

Note that this means that following arguments will not be executed if some
argument fails. I do not know if this is the best behaviour or not, but I am
implementing it like this here due to its simplicity to implement.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-08-31 15:53:27 +02:00
parent 08e4c304cd
commit 4ce16084ff
1 changed files with 3 additions and 1 deletions

View File

@ -44,14 +44,16 @@ a_dbus_send()
$DBUS_SEND --dest=$DBUS_DEST --type=method_call --print-reply \
$DBUS_PATH $DBUS_METHOD string:"$1" | tail -n +2
ret=$?
if [ "$ret" != 0 ] && [ "$ISATTY" != 0 ]; then
if [ "$ret" != 0 ] && [ "$FATAL_ERRORS" != 0 ]; then
echo "E: $DBUS_SEND failed." >&2
exit $ret
fi
}
FATAL_ERRORS="$ISATTY"
if [ $# -ne 0 ]
then
FATAL_ERRORS="1"
for arg in "$@" ; do
a_dbus_send "$arg"
done