Version: 1:7.7+19
I stumbled across this one today when trying to use i3 with Plasma as
documented at user.base.kde.org, that is with:
Exec=env KDEWM=/usr/bin/i3 /usr/bin/startkde
Some proposed fixes were:
1. Not quoting "$1". Not a good idea: In this case /usr/bin/which tries
to locate each argument:
$ which env KDEWM=/usr/bin/i3 /usr/bin/startkde
/usr/bin/env
KDEWM=/usr/bin/i3 not found
/usr/bin/startkde
2. Removing the arguments with "${1%% *}". Simple, but there are
possibly two problems:
a) Does this work with all shells? /etc/X11/Xsession may be sourced by
various shells. At least bash, dash and zsh seem to be fine, though.
b) It handles only space, but I think it should handle all white-space
(there may actually be more complications for full .desktop file
handling, because the desktop entry spec allows \s for space and such; I
will ignore those) and possibly escaped/quoted spaces (foo\ bar or "foo
bar").
My proposal is to add a function to 20x11-common_process-args:
which_first() {
/usr/bin/which $1
}
... and replace
$(/usr/bin/which "$1" || true)
with:
$(which_first $1 || true)
This leaves more accurate argument handling to the shell. A
corresponding patch is attached.
(OT: While I do appreciate all the work that goes into the project, it's
a pity that this bug and its related bugs are still open after 8+ years,
even with Severity: important and some ways to fix. I would love to be
able to just submit a PR and have it fixed within hours.)
--- 20x11-common_process-args.orig 2019-10-27 02:33:33.170572511 +0200
+++ 20x11-common_process-args 2019-10-27 02:34:08.222958960 +0200
@@ -14,6 +14,10 @@
fi
}
+which_first() {
+ /usr/bin/which $1
+}
+
# Determine how many arguments were provided.
case $# in
0)
@@ -45,7 +49,7 @@
;;
*)
# Specific program was requested.
- STARTUP_FULL_PATH=$(/usr/bin/which "$1" || true)
+ STARTUP_FULL_PATH=$(which_first $1 || true)
if [ -n "$STARTUP_FULL_PATH" ] && [ -e "$STARTUP_FULL_PATH" ]; then
if [ -x "$STARTUP_FULL_PATH" ]; then
STARTUP="$1"