Skip to content

Instantly share code, notes, and snippets.

@x-yuri
Created September 13, 2017 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x-yuri/d933972a2f1c42a49fc7999b8d5c50b9 to your computer and use it in GitHub Desktop.
Save x-yuri/d933972a2f1c42a49fc7999b8d5c50b9 to your computer and use it in GitHub Desktop.
[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