```
Applications should note that the standard PATH to the shell cannot be assumed to be either /bin/sh or /usr/bin/sh, and should be determined by interrogation of the PATH returned by getconf PATH, ensuring that the returned pathname is an absolute pathname and not a shell built-in.
```
POSIX and SUS both say the same thing about this. This will also fix awesome-client on *BSD.
This is necessary when being run with a tty that has no width, which
happens when using https://github.com/metakirby5/codi.vim/ in Vim 8 (but
not Neovim), where rlwrap complains as follows:
> rlwrap: error: My terminal reports width=0 (is it emacs?) I can't
> handle this, sorry!
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>
In some languages, invoking commands with command-line arguments is
significantly simpler than setting up pipes for writing to a command's
standard input.
This adds an additional way for sending commands through awesome-client;
so all of these will be equivalent:
$ awesome-client 'awesome.restart()'
$ echo 'awesome.restart()' | awesome-client
$ awesome-client <<<'awesome.restart()'
$ awesome-client
awesome# awesome.restart()
awesome# ^D
$
Note that this sends each command line argument as a separate message
over dbus.
- exit with a non-zero status code when dbus-send fails.
If awesome does not respond to the D-Bus message, e.g. because it is not
running (yet), awesome-client now returns with a non-zero return code.
This can be used to check if awesome has finished starting up, which is
meant to be used for the functional test runner.
- changed the shebang to use bash directly, which simplifies the logic
to detect/handle "bash as /bin/sh" and allows to use `set -o pipefail`
(which makes handling the D-Bus error easier - without using a subshell).
- fix the prompt: now with trailing space, and the prompt is actually used
(which wasn't the case with /bin/sh not pointing at bash before).
Closes https://github.com/awesomeWM/awesome/pull/304.
-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 should make this more usable again. The old C version used readline, if
possible and now the new bash version does too. :)
The idea to use rlwrap is from jd and it's a good one.
Signed-off-by: Uli Schlachter <psychon@znc.in>