Ottavio Caruso <
ottavio2006...@yahoo.com>:
> Am 03/04/2023 um 16:05 schrieb Kenny McCormack:
>> In article <u0erqc$30uas$
1...@dont-email.me>,
>> Ottavio Caruso <
ottavio2006...@yahoo.com> wrote:
>>> I'm trying to narrow this down to either my script or Firefox
>>> itself.
>>>
>>> I have a rudimentary shell launcher:
>>>
>>>
>>> $ cat opt/bin/ff-accel
>>> #!/bin/sh
>>> env MOZ_X11_EGL=1 /home/oc/opt/firefox/firefox
>>
>> This needs to be:
>>
>> env MOZ_X11_EGL=1 /home/oc/opt/firefox/firefox "$@"
>
> Thanks. I just realised that yesterday night on my way home. But
> are the quotes around $@ necessary?
Yes, they are. The POSIX standard
(<
http://www.opengroup.org/onlinepubs/9699919799/mindex.html>)
describes in the volume about the shell command language and the
utilities (follow the "XCU" link,
<
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/toc.html>)
what it's going to happen if you don't use the quotes (follow the
"field splitting" link,
<
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05>).
In short: When not using the quotes, the values of the shell
parameter (in your use case: each of the positional parameters
("$@")) is split into parts at each character which is part of
the set of characters specified by the "IFS" shell variable.
Depending on further conditions these parts are then matched
against filenames. This is surely not what you want with your
script which should pass its positional parameters unmodified to
firefox.
=> Using quotes is the "normal way" of passing values of shell
parameters into commands. (That it is the more complicated
expression than just leaving the quotes away might have its
origin in the historic development of the shell programming
language.)
>> BTW, why do you use "env"? Is that necessary, or is that just
>> your general practice?
>
The shell has got a built‐in mechanism of specifying environment
variables when invoking a simple command (in
<
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/toc.html>
follow the "simple commands" link
<
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01>)
which has got similar capabilities (not exactly the same) like
the «env» program: To use it in a shell command line, just put
the environment assignments in front of the simple command.