[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Am I doing it all wrong?
From: |
Saku Laesvuori |
Subject: |
Re: Am I doing it all wrong? |
Date: |
Sun, 28 Aug 2022 17:10:54 +0300 |
> > Also, that should probably be "$@", just in case.
>
> I don't think it'll make any difference; if, say, "foo" "bar" "baz" is
> passed, both $@ and "$@" will expand to "foo" "bar" "baz" (yes, bypassing
> the quotes).
>
> According to POSIX.1-2017's specification of `sh`:
>
> When the expansion occurs within double-quotes, the behavior is unspecified
> unless one of the following is true:
>
> + Field splitting [...] would be performed if the expansion were not within
> double-quotes [...].
>
> + [...]
>
> So, $@ == "$@".
It does actually make a difference if the arguments have spaces. Given
arguments "foo" and "foo bar", $@ expands to "foo" "foo" "bar" and "$@"
expands to "foo" "foo bar".
- Saku Laesvuori
signature.asc
Description: PGP signature
- Am I doing it all wrong?, jgart, 2022/08/27
- Re: Am I doing it all wrong?, Ricardo Wurmus, 2022/08/27
- Re: Am I doing it all wrong?, jgart, 2022/08/27
- Re: Am I doing it all wrong?, (, 2022/08/27
- Re: Am I doing it all wrong?, (, 2022/08/27
- Re: Am I doing it all wrong?, (, 2022/08/27
- Re: Am I doing it all wrong?, Csepp, 2022/08/28
- Re: Am I doing it all wrong?, (, 2022/08/28
- Re: Am I doing it all wrong?,
Saku Laesvuori <=
Re: Am I doing it all wrong?, (, 2022/08/27
Re: Am I doing it all wrong?, Csepp, 2022/08/28