Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[yuri@yuri-nb /srv/http/s1/5] cat 1.sh
#!/usr/bin/env bash
set -eu
countArgs () { echo "$#"; }
arr=('')
countArgs "${arr[@]+${arr[@]}}"
countArgs ${arr[@]+"${arr[@]}"}
arr=()
countArgs "${arr[@]+${arr[@]}}"
countArgs ${arr[@]+"${arr[@]}"}
[yuri@yuri-nb /srv/http/s1/5] ./1.sh
1
1
0
0
[yuri@yuri-nb /srv/http/s1/5] bash --version
GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment