git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/6] CodingGuidelines: describe "export VAR=VAL" rule

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 6, 2024, 05:11 UTC
Message-ID
<CAPig+cRjqe-rgYf5UZr9KXmfSw98ZoYjPo5PKhwzRaC-svwshA@mail.gmail.com>
In-Reply-To
<20240406000902.3082301-2-gitster@pobox.com>
On Fri, Apr 5, 2024 at 8:09 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 10 quoted lines
> https://lore.kernel.org/git/201307081121.22769.tboegi@web.de/
> resulted in 9968ffff (test-lint: detect 'export FOO=bar',
> 2013-07-08) to add a rule to t/check-non-portable-shell.pl script to
> reject
>
>         export VAR=VAL
>
> and suggest us to instead write it as "export VAR" followed by
> "VAR=VAL".  This however was not spelled out in the CodingGuidelines
> document.
I suspect you meant:
   ... and suggest us to instead write it as "VAR=VAL" followed by
   "export VAR".
Show 13 quoted lines
> We may want to re-evaluate the rule since it is from ages ago, but
> for now, let's make the written rule and what the automation enforces
> consistent.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> @@ -188,6 +188,12 @@ For shell scripts specifically (not exhaustive):
>     hopefully nobody starts using "local" before they are reimplemented
>     in C ;-)
>
> + - Some versions of shell do not understand "export variable=value",
> +   so we write "export variable" and "variable=value" on separae
s/separae/separate/
Here too, it might be clearer to swap around the pieces:
    ... so we write "variable=value" and "export variable" on...
> +   lines.  Note that this was reported in 2013 and the situation might
> +   have changed since then.  We'd need to re-evaluate this rule,
> +   together with the rule in t/check-non-portable-shell.pl script.

The bit starting at "Note that..." seems more appropriate for the commit message (which is already the case) or a To-Do list. People reading this document are likely newcomers looking for concrete instructions about how to code for this project, and this sort of To-Do item isn't going to help them. (If anything, it might confuse them into ignoring the advice to split `export foo=bar` into two statements, which will result in reviewers asking them to reroll.)

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 23 in “local VAR="VAL"”
  1. 0/6 local VAR="VAL"Junio C Hamano, Apr 6, 2024
  2. 1/6 CodingGuidelines: describe "export VAR=VAL" ruleJunio C Hamano, Apr 6, 2024
  3. Eric SunshineApr 6, 2024
  4. Junio C HamanoApr 6, 2024
  5. Andreas SchwabApr 6, 2024
  6. Junio C HamanoApr 6, 2024
  7. Eric SunshineApr 6, 2024
  8. 3/6 t: local VAR="VAL" (quote positional parameters)Junio C Hamano, Apr 6, 2024
  9. Patrick SteinhardtApr 8, 2024
  10. Junio C HamanoApr 8, 2024
  11. 2/6 CodingGuidelines: quote assigned value in 'local var=$val'Junio C Hamano, Apr 6, 2024
  12. rsbecker@nexbridge.comApr 6, 2024
  13. Junio C HamanoApr 6, 2024
  14. Eric SunshineApr 6, 2024
  15. Junio C HamanoApr 6, 2024
  16. 4/6 t: local VAR="VAL" (quote command substitution)Junio C Hamano, Apr 6, 2024
  17. 5/6 t: local VAR="VAL" (quote ${magic-reference})Junio C Hamano, Apr 6, 2024
  18. 6/6 t: teach lint that RHS of 'local VAR=VAL' needs to be quotedJunio C Hamano, Apr 6, 2024
  19. Jeff KingApr 7, 2024
  20. Junio C HamanoApr 8, 2024
  21. Jeff KingApr 8, 2024
  22. 7/6 t0610: local VAR="VAL" fixJunio C Hamano, Apr 6, 2024
  23. 8/6 t1016: local VAR="VAL" fixJunio C Hamano, Apr 6, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.