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

[PATCH v2 0/8] git-prompt: support more shells v2

From
AGAvi Halachmi via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 15, 2024, 13:14 UTC
Message-ID
<pull.1750.v2.git.git.1723727653.gitgitgadget@gmail.com>
In-Reply-To
<pull.1750.git.git.1721762306.gitgitgadget@gmail.com>

This addresses review comment on part 6/8 (git-prompt: add fallback for shells without $'...') which requested to use one form for all shells instead $'...' where supported and a fallback otherwise.

Parts 7/8 and 8/8 are rebased trivially on top of updated part 6/8.

Using the GitGitGadget github interface, so I don't know whether it will send only the 3 updated patches, or all 8 as v2.

Potential followups which this series does not address:
 * A comment on part 6/8 suggested to add to CodingGuidelines some of the
   guidelines in the commit messages, without being specific, likely
   referring to part 5/8 (git-prompt: add some missing quotes).
 * The same comment to 6/8 posted a suggested patch to CodingGuidelines to
   disallow bashism [[...]], and disallow $'...' - which is comliant (POSIX
   2024) but not supported in all shells.
Avi Halachmi (:avih) (8):
  git-prompt: use here-doc instead of here-string
  git-prompt: fix uninitialized variable
  git-prompt: don't use shell arrays
  git-prompt: replace [[...]] with standard code
  git-prompt: add some missing quotes
  git-prompt: don't use shell $'...'
  git-prompt: ta-da! document usage in other shells
  git-prompt: support custom 0-width PS1 markers
 contrib/completion/git-prompt.sh | 191 ++++++++++++++++++++-----------
 1 file changed, 126 insertions(+), 65 deletions(-)
base-commit: d19b6cd2dd72dc811f19df4b32c7ed223256c3ee
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1750%2Favih%2Fprompt-compat-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1750/avih/prompt-compat-v2
Pull-Request: https://github.com/git/git/pull/1750
Range-diff vs v1:
 1:  9ce5ddadf0b = 1:  9ce5ddadf0b git-prompt: use here-doc instead of here-string
 2:  680ecb52404 = 2:  680ecb52404 git-prompt: fix uninitialized variable
 3:  7e994eae7bc = 3:  7e994eae7bc git-prompt: don't use shell arrays
 4:  232340902a1 = 4:  232340902a1 git-prompt: replace [[...]] with standard code
 5:  4f77b7eb7f1 = 5:  4f77b7eb7f1 git-prompt: add some missing quotes
 6:  1c1b58e20ca ! 6:  363b7015763 git-prompt: add fallback for shells without $'...'
     @@ Metadata
      Author: Avi Halachmi (:avih) <avihpit@yahoo.com>
      
       ## Commit message ##
     -    git-prompt: add fallback for shells without $'...'
     +    git-prompt: don't use shell $'...'
      
          $'...' is new in POSIX (2024), and some shells support it in recent
          versions, while others have had it for decades (bash, zsh, ksh93).
      
          However, there are still enough shells which don't support it, and
     -    it's cheap to provide a fallback for them, so let's do that instead
     -    of dismissing it as "it's compliant".
     +    it's cheap to use an alternative form which works in all shells,
     +    so let's do that instead of dismissing it as "it's compliant".
     +
     +    It was agreed to use one form rather than $'...' where supported and
     +    fallback otherwise.
      
          shells where $'...' works:
          - bash, zsh, ksh93, mksh, busybox-ash, dash master, free/net bsd sh.
     @@ contrib/completion/git-prompt.sh
       __git_printf_supports_v=
       printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
       
     -+__git_SOH=$'\1' __git_STX=$'\2' __git_ESC=$'\33'
     -+__git_LF=$'\n' __git_CRLF=$'\r\n'
     -+
     -+if [ $'\101' != A ]; then  # fallback for shells without $'...'
     -+   __git_CRLF=$(printf "\r\n\1\2\33")  # CR LF SOH STX ESC
     -+   __git_ESC=${__git_CRLF#????}; __git_CRLF=${__git_CRLF%?}
     -+   __git_STX=${__git_CRLF#???};  __git_CRLF=${__git_CRLF%?}
     -+   __git_SOH=${__git_CRLF#??};   __git_CRLF=${__git_CRLF%?}
     -+   __git_LF=${__git_CRLF#?}
     -+fi
     ++# like __git_SOH=$'\001' etc but works also in shells without $'...'
     ++eval "$(printf '
     ++	__git_SOH="\001" __git_STX="\002" __git_ESC="\033"
     ++	__git_LF="\n" __git_CRLF="\r\n"
     ++')"
      +
       # stores the divergence from upstream in $p
       # used by GIT_PS1_SHOWUPSTREAM
 7:  4a086ffc360 = 7:  4aa75cdb5dd git-prompt: ta-da! document usage in other shells
 8:  f241c3ae1e4 = 8:  e71ddcd2232 git-prompt: support custom 0-width PS1 markers
-- 
gitgitgadget
Previous: avihNext: Avi Halachmi (:avih) via GitGitGadget
Message 28 of 80 in “git-prompt: support more shells”
  1. 0/8 git-prompt: support more shellsAvi Halachmi via GitGitGadget, Jul 23, 2024
  2. 1/8 git-prompt: use here-doc instead of here-stringAvi Halachmi (:avih) via GitGitGadget, Jul 23, 2024
  3. 2/8 git-prompt: fix uninitialized variableAvi Halachmi (:avih) via GitGitGadget, Jul 23, 2024
  4. 3/8 git-prompt: don't use shell arraysAvi Halachmi (:avih) via GitGitGadget, Jul 23, 2024
  5. 4/8 git-prompt: replace [[...]] with standard codeAvi Halachmi (:avih) via GitGitGadget, Jul 23, 2024
  6. 5/8 git-prompt: add some missing quotesAvi Halachmi (:avih) via GitGitGadget, Jul 23, 2024
  7. Junio C HamanoJul 23, 2024
  8. avihJul 24, 2024
  9. 6/8 git-prompt: add fallback for shells without $'...'Avi Halachmi (:avih) via GitGitGadget, Jul 23, 2024
  10. Junio C HamanoJul 23, 2024
  11. avihJul 24, 2024
  12. avihJul 25, 2024
  13. avihJul 25, 2024
  14. Junio C HamanoJul 25, 2024
  15. avihJul 25, 2024
  16. Junio C HamanoJul 25, 2024
  17. avihAug 14, 2024
  18. Junio C HamanoAug 14, 2024
  19. avihAug 15, 2024
  20. Junio C HamanoAug 15, 2024
  21. 7/8 git-prompt: ta-da! document usage in other shellsAvi Halachmi (:avih) via GitGitGadget, Jul 23, 2024
  22. 8/8 git-prompt: support custom 0-width PS1 markersAvi Halachmi (:avih) via GitGitGadget, Jul 23, 2024
  23. brian m. carlsonJul 23, 2024
  24. avihJul 24, 2024
  25. Junio C HamanoJul 24, 2024
  26. Junio C HamanoJul 24, 2024
  27. avihJul 24, 2024
  28. 0/8 git-prompt: support more shells v2Avi Halachmi via GitGitGadget, Aug 15, 2024
  29. 1/8 git-prompt: use here-doc instead of here-stringAvi Halachmi (:avih) via GitGitGadget, Aug 15, 2024
  30. Patrick SteinhardtAug 16, 2024
  31. avihAug 16, 2024
  32. Patrick SteinhardtAug 16, 2024
  33. 2/8 git-prompt: fix uninitialized variableAvi Halachmi (:avih) via GitGitGadget, Aug 15, 2024
  34. 3/8 git-prompt: don't use shell arraysAvi Halachmi (:avih) via GitGitGadget, Aug 15, 2024
  35. Patrick SteinhardtAug 16, 2024
  36. avihAug 16, 2024
  37. Patrick SteinhardtAug 16, 2024
  38. avihAug 16, 2024
  39. Patrick SteinhardtAug 16, 2024
  40. 4/8 git-prompt: replace [[...]] with standard codeAvi Halachmi (:avih) via GitGitGadget, Aug 15, 2024
  41. Junio C HamanoAug 15, 2024
  42. avihAug 16, 2024
  43. Junio C HamanoAug 16, 2024
  44. 5/8 git-prompt: add some missing quotesAvi Halachmi (:avih) via GitGitGadget, Aug 15, 2024
  45. Junio C HamanoAug 15, 2024
  46. avihAug 15, 2024
  47. Junio C HamanoAug 15, 2024
  48. avihAug 15, 2024
  49. 6/8 git-prompt: don't use shell $'...'Avi Halachmi (:avih) via GitGitGadget, Aug 15, 2024
  50. 7/8 git-prompt: ta-da! document usage in other shellsAvi Halachmi (:avih) via GitGitGadget, Aug 15, 2024
  51. Patrick SteinhardtAug 16, 2024
  52. avihAug 16, 2024
  53. 8/8 git-prompt: support custom 0-width PS1 markersAvi Halachmi (:avih) via GitGitGadget, Aug 15, 2024
  54. Junio C HamanoAug 15, 2024
  55. Patrick SteinhardtAug 16, 2024
  56. 0/8 git-prompt: support more shells v3Avi Halachmi via GitGitGadget, Aug 17, 2024
  57. 1/8 git-prompt: use here-doc instead of here-stringAvi Halachmi (:avih) via GitGitGadget, Aug 17, 2024
  58. 2/8 git-prompt: fix uninitialized variableAvi Halachmi (:avih) via GitGitGadget, Aug 17, 2024
  59. 3/8 git-prompt: don't use shell arraysAvi Halachmi (:avih) via GitGitGadget, Aug 17, 2024
  60. 4/8 git-prompt: replace [[...]] with standard codeAvi Halachmi (:avih) via GitGitGadget, Aug 17, 2024
  61. 5/8 git-prompt: add some missing quotesAvi Halachmi (:avih) via GitGitGadget, Aug 17, 2024
  62. Eric SunshineAug 17, 2024
  63. avihAug 17, 2024
  64. Junio C HamanoAug 17, 2024
  65. avihAug 17, 2024
  66. 6/8 git-prompt: don't use shell $'...'Avi Halachmi (:avih) via GitGitGadget, Aug 17, 2024
  67. 7/8 git-prompt: ta-da! document usage in other shellsAvi Halachmi (:avih) via GitGitGadget, Aug 17, 2024
  68. 8/8 git-prompt: support custom 0-width PS1 markersAvi Halachmi (:avih) via GitGitGadget, Aug 17, 2024
  69. 0/8 git-prompt: support more shells v4Avi Halachmi via GitGitGadget, Aug 20, 2024
  70. 1/8 git-prompt: use here-doc instead of here-stringAvi Halachmi (:avih) via GitGitGadget, Aug 20, 2024
  71. 2/8 git-prompt: fix uninitialized variableAvi Halachmi (:avih) via GitGitGadget, Aug 20, 2024
  72. 3/8 git-prompt: don't use shell arraysAvi Halachmi (:avih) via GitGitGadget, Aug 20, 2024
  73. 4/8 git-prompt: replace [[...]] with standard codeAvi Halachmi (:avih) via GitGitGadget, Aug 20, 2024
  74. 5/8 git-prompt: add some missing quotesAvi Halachmi (:avih) via GitGitGadget, Aug 20, 2024
  75. 6/8 git-prompt: don't use shell $'...'Avi Halachmi (:avih) via GitGitGadget, Aug 20, 2024
  76. 7/8 git-prompt: ta-da! document usage in other shellsAvi Halachmi (:avih) via GitGitGadget, Aug 20, 2024
  77. 8/8 git-prompt: support custom 0-width PS1 markersAvi Halachmi (:avih) via GitGitGadget, Aug 20, 2024
  78. Junio C HamanoAug 20, 2024
  79. avihAug 20, 2024
  80. avihAug 28, 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.