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

Re: [PATCH] CodingGuidelines: quote assigned value with "local" and "export"

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 5, 2024, 19:36 UTC
Message-ID
<xmqqr0fjtxei.fsf@gitster.g>
In-Reply-To
<20240405174859.GE2529133@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 22 quoted lines
>> + - Some versions of dash has broken variable assignment when prefixed
>> +   with "local", "export", and "readonly", in that the value to be
>> +   assigned goes through field splitting at $IFS unless quoted.  
>> +
>> +   DO NOT write:
>> +
>> +     local variable=$value           ;# wrong
>> +     export variable=$(command args) ;# wrong
>> +
>> +   and instead write:
>> +
>> +     local variable="$value"
>> +     export variable="$(command args)"
>
> I think that is a good rule for "local", but I thought we did not allow
> "export foo=bar" at all, and required:
>
>   foo=bar
>   export foo
>
> If that was only because of this bug, it would be nice to loosen the
> rules a bit.

That rule in Documentation/CodingGuidelines predates the discovery of this bug. I have this vague feeling that it was for the shell on old Solaris, which would not matter to us anymore, but I do not remember.

As we are not showing "readonly" in the "DO NOT/DO" example above, we should probably drop the "export" example and discuss it separately and decide if it makes sense to loosen the "export var" vs "export var=val" rule.

Thanks.
Previous: Jeff KingNext: Junio C Hamano
Message 21 of 106 in “t: exercise Git/JGit reftable compatibility”
  1. 00/12 t: exercise Git/JGit reftable compatibilityPatrick Steinhardt, Apr 4, 2024
  2. 01/12 ci: rename "runs_on_pool" to "distro"Patrick Steinhardt, Apr 4, 2024
  3. 02/12 ci: expose distro name in dockerized GitHub jobsPatrick Steinhardt, Apr 4, 2024
  4. 03/12 ci: allow skipping sudo on dockerized jobsPatrick Steinhardt, Apr 4, 2024
  5. 04/12 ci: drop duplicate package installation for "linux-gcc-default"Patrick Steinhardt, Apr 4, 2024
  6. 05/12 ci: convert "install-dependencies.sh" to use "/bin/sh"Patrick Steinhardt, Apr 4, 2024
  7. 06/12 ci: merge custom PATH directoriesPatrick Steinhardt, Apr 4, 2024
  8. 07/12 ci: merge scripts which install dependenciesPatrick Steinhardt, Apr 4, 2024
  9. 08/12 ci: make Perforce binaries executable for all usersPatrick Steinhardt, Apr 4, 2024
  10. Josh SteadmonApr 5, 2024
  11. Patrick SteinhardtApr 8, 2024
  12. 09/12 ci: install JGit dependencyPatrick Steinhardt, Apr 4, 2024
  13. 10/12 t06xx: always execute backend-specific testsPatrick Steinhardt, Apr 4, 2024
  14. 11/12 t0610: fix non-portable variable assignmentPatrick Steinhardt, Apr 4, 2024
  15. Eric SunshineApr 5, 2024
  16. Patrick SteinhardtApr 5, 2024
  17. Junio C HamanoApr 5, 2024
  18. CodingGuidelines: quote assigned value with "local" and "export"Junio C Hamano, Apr 5, 2024
  19. Junio C HamanoApr 5, 2024
  20. Jeff KingApr 5, 2024
  21. Junio C HamanoApr 5, 2024
  22. Junio C HamanoApr 5, 2024
  23. Jeff KingApr 7, 2024
  24. Patrick SteinhardtApr 5, 2024
  25. 12/12 t0612: add tests to exercise Git/JGit reftable compatibilityPatrick Steinhardt, Apr 4, 2024
  26. Han-Wen NienhuysApr 4, 2024
  27. Patrick SteinhardtApr 5, 2024
  28. Han-Wen NienhuysApr 6, 2024
  29. Patrick SteinhardtApr 6, 2024
  30. Patrick SteinhardtApr 8, 2024
  31. Patrick SteinhardtApr 4, 2024
  32. 00/12 t: exercise Git/JGit reftable compatibilityPatrick Steinhardt, Apr 8, 2024
  33. 02/12 ci: expose distro name in dockerized GitHub jobsPatrick Steinhardt, Apr 8, 2024
  34. 03/12 ci: allow skipping sudo on dockerized jobsPatrick Steinhardt, Apr 8, 2024
  35. Toon claesApr 10, 2024
  36. Junio C HamanoApr 10, 2024
  37. Patrick SteinhardtApr 11, 2024
  38. 04/12 ci: drop duplicate package installation for "linux-gcc-default"Patrick Steinhardt, Apr 8, 2024
  39. 05/12 ci: convert "install-dependencies.sh" to use "/bin/sh"Patrick Steinhardt, Apr 8, 2024
  40. Justin ToblerApr 10, 2024
  41. Patrick SteinhardtApr 11, 2024
  42. 06/12 ci: merge custom PATH directoriesPatrick Steinhardt, Apr 8, 2024
  43. 07/12 ci: merge scripts which install dependenciesPatrick Steinhardt, Apr 8, 2024
  44. 08/12 ci: make Perforce binaries executable for all usersPatrick Steinhardt, Apr 8, 2024
  45. 09/12 ci: install JGit dependencyPatrick Steinhardt, Apr 8, 2024
  46. 10/12 t06xx: always execute backend-specific testsPatrick Steinhardt, Apr 8, 2024
  47. 11/12 t0610: fix non-portable variable assignmentPatrick Steinhardt, Apr 8, 2024
  48. Eric SunshineApr 8, 2024
  49. Patrick SteinhardtApr 8, 2024
  50. 12/12 t0612: add tests to exercise Git/JGit reftable compatibilityPatrick Steinhardt, Apr 8, 2024
  51. Eric SunshineApr 8, 2024
  52. Junio C HamanoApr 8, 2024
  53. Eric SunshineApr 8, 2024
  54. Eric SunshineApr 8, 2024
  55. Patrick SteinhardtApr 8, 2024
  56. Jeff KingApr 8, 2024
  57. Junio C HamanoApr 8, 2024
  58. Junio C HamanoApr 8, 2024
  59. Justin ToblerApr 10, 2024
  60. Patrick SteinhardtApr 11, 2024
  61. 01/12 ci: rename "runs_on_pool" to "distro"Patrick Steinhardt, Apr 8, 2024
  62. Junio C HamanoApr 9, 2024
  63. Patrick SteinhardtApr 9, 2024
  64. Junio C HamanoApr 9, 2024
  65. Patrick SteinhardtApr 9, 2024
  66. 0/2 t0610: fix umask testsPatrick Steinhardt, Apr 9, 2024
  67. 1/2 t0610: make `--shared=` tests reusablePatrick Steinhardt, Apr 9, 2024
  68. 2/2 t0610: execute git-pack-refs(1) with specified umaskPatrick Steinhardt, Apr 9, 2024
  69. Justin ToblerApr 10, 2024
  70. 00/13 t: exercise Git/JGit reftable compatibilityPatrick Steinhardt, Apr 11, 2024
  71. 01/13 ci: rename "runs_on_pool" to "distro"Patrick Steinhardt, Apr 11, 2024
  72. 02/13 ci: expose distro name in dockerized GitHub jobsPatrick Steinhardt, Apr 11, 2024
  73. 03/13 ci: skip sudo when we are already rootPatrick Steinhardt, Apr 11, 2024
  74. 04/13 ci: drop duplicate package installation for "linux-gcc-default"Patrick Steinhardt, Apr 11, 2024
  75. 05/13 ci: convert "install-dependencies.sh" to use "/bin/sh"Patrick Steinhardt, Apr 11, 2024
  76. 06/13 ci: merge custom PATH directoriesPatrick Steinhardt, Apr 11, 2024
  77. 07/13 ci: fix setup of custom path for GitLab CIPatrick Steinhardt, Apr 11, 2024
  78. Eric SunshineApr 11, 2024
  79. Patrick SteinhardtApr 11, 2024
  80. 08/13 ci: merge scripts which install dependenciesPatrick Steinhardt, Apr 11, 2024
  81. 09/13 ci: make Perforce binaries executable for all usersPatrick Steinhardt, Apr 11, 2024
  82. 10/13 ci: install JGit dependencyPatrick Steinhardt, Apr 11, 2024
  83. 11/13 t06xx: always execute backend-specific testsPatrick Steinhardt, Apr 11, 2024
  84. 12/13 t0610: fix non-portable variable assignmentPatrick Steinhardt, Apr 11, 2024
  85. 13/13 t0612: add tests to exercise Git/JGit reftable compatibilityPatrick Steinhardt, Apr 11, 2024
  86. 00/13 t: exercise Git/JGit reftable compatibilityPatrick Steinhardt, Apr 12, 2024
  87. 01/13 ci: rename "runs_on_pool" to "distro"Patrick Steinhardt, Apr 12, 2024
  88. 02/13 ci: expose distro name in dockerized GitHub jobsPatrick Steinhardt, Apr 12, 2024
  89. 03/13 ci: skip sudo when we are already rootPatrick Steinhardt, Apr 12, 2024
  90. 04/13 ci: drop duplicate package installation for "linux-gcc-default"Patrick Steinhardt, Apr 12, 2024
  91. 05/13 ci: convert "install-dependencies.sh" to use "/bin/sh"Patrick Steinhardt, Apr 12, 2024
  92. 06/13 ci: merge custom PATH directoriesPatrick Steinhardt, Apr 12, 2024
  93. 07/13 ci: fix setup of custom path for GitLab CIPatrick Steinhardt, Apr 12, 2024
  94. 08/13 ci: merge scripts which install dependenciesPatrick Steinhardt, Apr 12, 2024
  95. 09/13 ci: make Perforce binaries executable for all usersPatrick Steinhardt, Apr 12, 2024
  96. 10/13 ci: install JGit dependencyPatrick Steinhardt, Apr 12, 2024
  97. 11/13 t06xx: always execute backend-specific testsPatrick Steinhardt, Apr 12, 2024
  98. 12/13 t0610: fix non-portable variable assignmentPatrick Steinhardt, Apr 12, 2024
  99. 13/13 t0612: add tests to exercise Git/JGit reftable compatibilityPatrick Steinhardt, Apr 12, 2024
  100. Justin ToblerMay 3, 2024
  101. Patrick SteinhardtMay 3, 2024
  102. Patrick SteinhardtMay 3, 2024
  103. Justin ToblerMay 3, 2024
  104. Patrick SteinhardtMay 3, 2024
  105. Justin ToblerMay 4, 2024
  106. Patrick SteinhardtMay 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.