Reputation: 141070
I need to change the following Bash code to Zsh
TODO_OPTIONS="--timeout --summary"
cd ()
{
builtin cd "$@"
RV=$?
[ $RV = 0 -a -r .todo ] && devtodo ${TODO_OPTIONS}
return $RV
}
pushd ()
{
builtin pushd "$@"
RV=$?
[ $RV = 0 -a -r .todo ] && devtodo ${TODO_OPTIONS}
return $RV
}
popd ()
{
builtin popd "$@"
RV=$?
[ $RV = 0 -a -r .todo ] && devtodo ${TODO_OPTIONS}
return $RV
}
# Run todo initially upon login
devtodo ${TODO_OPTIONS}
I get the following error when I start Zsh with the code
todo: error, unknown argument '--timeout --summary', try --help
I feel that Zsh cannot understand the following line
[ $RV = 0 -a -r .todo ] && devtodo ${TODO_OPTIONS}
Other commands in the first code seems to be right for Zsh.
How can you convert the code to Zsh?
Upvotes: 5
Views: 1672
Reputation: 34145
You're saving the text as one string/object, instead of as a simple "thing to substitute". You can either save the string properly:
TODO_OPTIONS=(--timeout --summary)
....
devtodo ${TODO_OPTIONS}
Or run word splitting on your variable:
TODO_OPTIONS="--timeout --summary"
....
devtodo ${=TODO_OPTIONS}
Upvotes: 4