ZSH support
Hi
Issue Argbash doesn't seem to support ZSH ?
Symptom When running with ZSH I'm seeing the following error: Error during argument parsing, possibly an Argbash bug
Which points to the eval line below
assign_positional_args ()
{
# We have an array of variables to which we want to save positional args values.
# This array is able to hold array elements as targets.
_positional_names=('_arg_task' )
for (( ii = 0; ii < ${#_positionals[@]}; ii++))
do
eval "${_positional_names[ii]}=\${_positionals[ii]}" || die "Error during argument parsing, possibly an Argbash bug." 1
done
}
Workaround
Runs fine with #!/bin/bash
Many thanks
Hello, when generating the output, use -t posix-script. That way, you will get a script without bashisms, but it will only support the POSIX CLI standard, not the GNU one.
Perfect, thanks @matejak Closing issue.
For anyone, like me, that comes here and has no possibility to run bash on the system:
I think the issue is that ZSH handles word splitting differently than BASH. You can force ZSH to split words like bash with setopt shwordsplit - Add this to the beginning of your script and argbash should run on ZSH.
Tested on zsh 5.8.1 (x86_64-ubuntu-linux-gnu) (WSL2)
Very helpful article with explanation: https://scriptingosx.com/2019/08/moving-to-zsh-part-8-scripting-zsh/