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

Avi Halachmi via GitGitGadget
2024-07-23T19:18:31Z

Before this patchset only bash and zsh were supported.

After this patchset, the following shells work: bash, zsh, dash (since at
least 0.5.8), free/net bsd sh, busybox-ash, mksh, openbsd sh, pdksh(!),
Schily extended Bourne sh (bosh), yash.

The code should now be almost posix-compliant, with one big exception
("local" variables in functions) which is not simple to fix.

Shells which don't work, likely only due to missing "local": ksh93[u+m],
Schily minimal posix Bourne sh (pbosh), yash-posix-mode.

Most changes are trivial, like changing [[...]] to [...], with one exception
(git-prompt: don't use shell arrays) which changes few lines.

Tested with and without colors, with diversions from upstream, in git-svn
repos, and more, but I'm not considering it full coverage.

* avih

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: add fallback for shells without $'...'
git-prompt: ta-da! document usage in other shells
git-prompt: support custom 0-width PS1 markers

contrib/completion/git-prompt.sh | 196 +++++++++++++++++++++----------
1 file changed, 131 insertions(+), 65 deletions(-)

base-commit: d19b6cd2dd72dc811f19df4b32c7ed223256c3ee
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1750%2Favih%2Fprompt-compat-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1750/avih/prompt-compat-v1
Pull-Request: https://github.com/git/git/pull/1750
--
gitgitgadget