Xaxetrov / git-typo

A collection of easter eggs related to common typos in git
GNU General Public License v3.0
13 stars 3 forks source link

Check compability on different shell systems #5

Closed Xaxetrov closed 5 years ago

Xaxetrov commented 5 years ago

Bash and git bash for Windows are tested but no other shells.

CharlesGueunet commented 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.

Xaxetrov commented 5 years ago

OK thanks Charles !

Xaxetrov commented 5 years ago

@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.

CharlesGueunet commented 5 years ago

@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.

CharlesGueunet commented 5 years ago

@Xaxetrov Your new comparison also work on zsh, but not the array assignment for git commit --amen

Xaxetrov commented 5 years ago

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 ?

Xaxetrov commented 5 years ago

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

Xaxetrov commented 5 years ago

@CharlesGueunet Should be fixed now thanks to the "emulate" command.

CharlesGueunet commented 5 years ago

Yep, I confirm the fix works !