Closed Xaxetrov closed 5 years ago
string comparison in zsh
is made using =
. This results in a syntax error when git is called:
git:3: = not found
Using a single =
instead of ==
works for zsh
.
OK thanks Charles !
@Charles this doc says it is ok to use double =
symbol : http://zsh.sourceforge.net/Doc/Release/Conditional-Expressions.html. Is it wrong ? Anyways I will switch to a single symbol which is pure shell.
@Xaxetrov From your website:
A conditional expression is used with the [[ compound command to test attributes of files and to compare strings. Each expression can be constructed from one or more of the following unary or binary expressions:
However, in shellGitTypo.sh
conditional are written using [
, hence the error. Using [[
is certainly a way to fix this compatibility error as it is also supported by bash.
@Xaxetrov Your new comparison also work on zsh, but not the array assignment for git commit --amen
How about if the KSH_ARRAY otion is set ? http://zsh.sourceforge.net/Doc/Release/Parameters.html#Array-Subscripts If so, could I set it myself in the script ?
Alternatively, there are solutions to split a string using cut, awk or pure posix shell commands: https://unix.stackexchange.com/questions/312280/split-string-by-delimiter-and-get-n-th-element
@CharlesGueunet Should be fixed now thanks to the "emulate" command.
Yep, I confirm the fix works !
Bash and git bash for Windows are tested but no other shells.