Skip to content

Comments

kmscon-launch-gui: don't use eval#156

Merged
kdj0c merged 1 commit intoAetf:mainfrom
martinetd:wrapper-eval
Nov 15, 2025
Merged

kmscon-launch-gui: don't use eval#156
kdj0c merged 1 commit intoAetf:mainfrom
martinetd:wrapper-eval

Conversation

@martinetd
Copy link

@martinetd martinetd commented Nov 15, 2025

this eval is harmful as it makes it necessary to add one more level of escaping to the arguments.

Note this could break existing users, but given the script is recent I believe it is still worth improving.
If eval-like behaviour is required one can run sh -c ... for identical effect:

$ cat /tmp/t.sh
#!/bin/sh

echo --- no eval
"$@"
echo --- eval
eval "$@"
echo ---------------
$ /tmp/t.sh printf "%s\n" "test space"
--- no eval
test space
--- eval
testnspacen---------------
$ /tmp/t.sh sh -c 'printf "%s\n" "test space"'
--- no eval
test space
--- eval
printf: usage: printf [-v var] format [arguments]
---------------

Fixes: 4c2893a ("Add drmSetBackground and drmSetForeground escape codes")


(for simple commands like just running a session wrapper even with simple arguments this doesn't change anything, it would only break for an user using spaces or quotes)

this eval is harmful as it makes it necessary to add one more level of escaping
to the arguments.

Note this could break existing users, but given the script is recent I
believe it is still worth improving.
If eval-like behaviour is required one can run `sh -c ...` for identical
effect:
```
$ cat /tmp/t.sh
#!/bin/sh

echo --- no eval
"$@"
echo --- eval
eval "$@"
echo ---------------
$ /tmp/t.sh printf "%s\n" "test space"
--- no eval
test space
--- eval
testnspacen---------------
$ /tmp/t.sh sh -c 'printf "%s\n" "test space"'
--- no eval
test space
--- eval
printf: usage: printf [-v var] format [arguments]
---------------
```

Fixes: 4c2893a ("Add drmSetBackground and drmSetForeground escape codes")
Signed-off-by: Dominique Martinet <[email protected]>
@kdj0c
Copy link
Collaborator

kdj0c commented Nov 15, 2025

Good catch, thanks for your PR, the eval is not necessary.

@kdj0c kdj0c merged commit fbbc4f5 into Aetf:main Nov 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants