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
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.
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
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.