Skip to content

Instantly share code, notes, and snippets.

@jaychsu
Last active March 19, 2020 13:51
Show Gist options
  • Save jaychsu/e647615cc1649c0d1281b99cdc4dbd84 to your computer and use it in GitHub Desktop.
Save jaychsu/e647615cc1649c0d1281b99cdc4dbd84 to your computer and use it in GitHub Desktop.
Pass parameters in zsh
# https://stackoverflow.com/questions/42655304/how-do-i-check-if-a-variable-is-set-in-zsh
test() {
test2 $@
test3 $@
}
test2() {
if [[ $# -eq 0 ]]; then
echo 'no params'
else
echo $@
fi
}
test3() {
if [[ -n $1 ]]; then
echo $1
else
echo 'no params'
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment