Your shell is expanding the glob pattern [yyyy\d\d\d]*
so the actual number of arguments this results in depends on the contents of the current directory!
The [yyyy\d\d\d]
becomes a character class matching the characters y
and d
, and the *
matches anything that follows, so I'm guessing your current directory has 4 files that start with y
or d
. To see what it expands to, use echo
:
$ echo [yyyy\d\d\d]*
To make it work as intended, quote the argument:
$ ./stringmatch '[yyyy\d\d\d]*' yyyy1234