]> git.ipfire.org Git - thirdparty/git.git/commit
git-prompt: replace [[...]] with standard code
authorAvi Halachmi (:avih) <avihpit@yahoo.com>
Tue, 20 Aug 2024 01:48:28 +0000 (01:48 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Aug 2024 15:28:18 +0000 (08:28 -0700)
commitfe445a1026562dfeb4fa1b0ee93bdfe3b7422251
treecb215d239eafc4249124b7e328911b0c8504b151
parentf2e264e43f6065e05ed7c53395ed167fc33eea2a
git-prompt: replace [[...]] with standard code

The existing [[...]] tests were either already valid as standard [...]
tests, or only required minimal retouch:

Notes:

- [[...]] doesn't do field splitting and glob expansion, so $var
  or $(cmd...) don't need quoting, but [... does need quotes.

- [[ X == Y ]] when Y is a string is same as [ X = Y ], but if Y is
  a pattern, then we need:  case X in Y)... ; esac  .

- [[ ... && ... ]] was replaced with [ ... ] && [ ... ] .

- [[ -o <zsh-option> ]] requires [[...]], so put it in "eval" and only
  eval it in zsh, so other shells would not abort on syntax error
  (posix says [[ has unspecified results, shells allowed to reject it)

- ((x++)) was changed into x=$((x+1))  (yeah, not [[...]] ...)

Shells which accepted the previous forms:
- bash, zsh, ksh93, mksh, openbsd sh, pdksh.

Shells which didn't, and now can process it:
- dash, free/net bsd sh, busybox-ash, Schily Bourne sh, yash.

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-prompt.sh