Re: [PATCH 3/4] check-non-portable-shell: improve `VAR=val shell-func` detection
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 22, 2024, 21:57 UTC
- Message-ID
- <xmqq34o19jj1.fsf@gitster.g>
- In-Reply-To
- <CAO_smVhd_fWkC1=9r_ASCEPoM_rRap3DAWq--nq+6dQ8M8qzjQ@mail.gmail.com>
Kyle Lippincott <spectral@google.com> writes:
> Having just looked at the POSIX standard (I don't think I'm allowed to > copy from this document), the POSIX standard (POSIX.1-2024, at least) > explicitly leaves it unspecified whether the variable assignments > remain in effect after function execution.
True.
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_09_01_02
also says that it is unspecified if the variable gets exported, and older version of dash that comes on Ubuntu 20.04 chooses *not* to export, which was the test breakage that triggered this whole discussion. The thread can be seen here:
https://lore.kernel.org/git/xmqqbk2p9lwi.fsf_-_@gitster.g/
> Thanks for indulging my curiosity; should we include a statement in > the linter along the lines of `# POSIX.1-2024 explicitly does not > specify if variable assignment persists after executing a shell > function; some shells, such as ksh, have these variables remain.`?
Giving a review (either positive or negative is fine, as long as it is constructive) on the update to CodingGuidelines
https://lore.kernel.org/git/xmqqbk2p9lwi.fsf_-_@gitster.g/
may be a good place to start.
Thanks.