~kennylevinsen/greetd-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 2

[PATCH greetd-docs] Quote array expansion

Details
Message ID
<CZLRFO64VKCO.1PT595CV0CNJS@posteo.net>
DKIM signature
pass
Download raw message
Patch: +3 -3
See https://www.shellcheck.net/wiki/SC2068
---
 I forgot to add the patch in the last mail.

 index.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/index.md b/index.md
index 931ea52..d27207f 100644
--- a/index.md
+++ b/index.md
@@ -164,13 +164,13 @@ export QT_QPA_PLATFORM=wayland
export SDL_VIDEODRIVER=wayland
export _JAVA_AWT_WM_NONREPARENTING=1

exec sway $@
exec sway "$@"

#
# If you use systemd and want sway output to go to the journal, use this
# instead of the `exec sway $@` above:
# instead of the `exec sway "$@"` above:
#
#    exec systemd-cat --identifier=sway sway $@
#    exec systemd-cat --identifier=sway sway "$@"
#
```

-- 
2.44.0
Details
Message ID
<6b655b33-6e06-445e-862e-52985bb75b85@kl.wtf>
In-Reply-To
<CZLRFO64VKCO.1PT595CV0CNJS@posteo.net> (view parent)
DKIM signature
pass
Download raw message
On 3/5/24 11:55, Sertonix wrote:
> See https://www.shellcheck.net/wiki/SC2068
> ---
>   I forgot to add the patch in the last mail.
The blank mail was confusing indeed. :)
>
>   index.md | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/index.md b/index.md
> index 931ea52..d27207f 100644
> --- a/index.md
> +++ b/index.md
> @@ -164,13 +164,13 @@ export QT_QPA_PLATFORM=wayland
>   export SDL_VIDEODRIVER=wayland
>   export _JAVA_AWT_WM_NONREPARENTING=1
>   
> -exec sway $@
> +exec sway "$@"

The original form is intentional and not a bug.

For a wrapper script like this, you want `sway-run -c config -d` to 
ultimately call `sway -c config -d` - each original argument passed 
individually. With quotes, it becomes `sway "-c config -d"`, which is a 
single argument that sway would not understand.

SC2068 is for when the behavior is accidental, passing multiple 
arguments when only one was intended.
Details
Message ID
<CAMA_ASYZF++=6+AzRMrXEFck_=7OcaFP+jPJ9kS4mG=SZGBO2Q@mail.gmail.com>
In-Reply-To
<6b655b33-6e06-445e-862e-52985bb75b85@kl.wtf> (view parent)
DKIM signature
pass
Download raw message
On Tue, Mar 5, 2024 at 3:25 PM Kenny Levinsen <kl@kl.wtf> wrote:
>
> On 3/5/24 11:55, Sertonix wrote:
> > See https://www.shellcheck.net/wiki/SC2068
> > ---
> >   I forgot to add the patch in the last mail.
> The blank mail was confusing indeed. :)
> >
> >   index.md | 6 +++---
> >   1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/index.md b/index.md
> > index 931ea52..d27207f 100644
> > --- a/index.md
> > +++ b/index.md
> > @@ -164,13 +164,13 @@ export QT_QPA_PLATFORM=wayland
> >   export SDL_VIDEODRIVER=wayland
> >   export _JAVA_AWT_WM_NONREPARENTING=1
> >
> > -exec sway $@
> > +exec sway "$@"
>
> The original form is intentional and not a bug.
>
> For a wrapper script like this, you want `sway-run -c config -d` to
> ultimately call `sway -c config -d` - each original argument passed
> individually. With quotes, it becomes `sway "-c config -d"`, which is a
> single argument that sway would not understand.
>
> SC2068 is for when the behavior is accidental, passing multiple
> arguments when only one was intended.

The SC2068 warning is correct here. "$@" is a special case[1][2],
where double quotes result in a field for each positional parameter,
but omitting the double quotes would lead to each non-empty field
being a subject of further field splitting.
I.e. sway-run '--config' 'path with spaces' will exec 'sway'
'--config' 'path' 'with' 'spaces'.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_02
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06

-- 
With best regards,
Aleksei Bavshin
Details
Message ID
<e522c602-2a57-4e6a-9fb9-386e9e79c397@kl.wtf>
In-Reply-To
<CAMA_ASYZF++=6+AzRMrXEFck_=7OcaFP+jPJ9kS4mG=SZGBO2Q@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On 3/6/24 01:56, Aleksei Bavshin wrote:
> The SC2068 warning is correct here. "$@" is a special case[1][2],
> where double quotes result in a field for each positional parameter,
> but omitting the double quotes would lead to each non-empty field
> being a subject of further field splitting.
> I.e. sway-run '--config' 'path with spaces' will exec 'sway'
> '--config' 'path' 'with' 'spaces'.


Well then, I stand corrected! What a peculiar and inconsistent special-case.
Details
Message ID
<a20e1c54-aea1-405b-9f0a-0f599909be4f@kl.wtf>
In-Reply-To
<CZLRFO64VKCO.1PT595CV0CNJS@posteo.net> (view parent)
DKIM signature
pass
Download raw message
Apologies for my confusion, applied. Thanks!
Reply to thread Export thread (mbox)