Consider the following:
$ ksh -c '1(){ echo hi;};1'
ksh: 1: invalid function name
$ dash -c '1(){ echo hi;};1'
dash: 1: Syntax error: Bad function name
$ bash -c '1(){ echo hi;};1'
bash: `1': not a valid identifier
bash: 1: command not found
$ mksh -c '1(){ echo hi;};1'
hi
Basically, I was trying to declare functions 1
and 0
which would be shorthands for true
and false
, but as you can see I ran into problem with using numeric names in functions. Same behavior occurs with aliases and two-digit names.
Question is "why"? Is it mandated by POSIX? or just a quirk of bourne-like shells?
See also related question to this one.
Best Answer
POSIX says:
And:
So a word beginning with a digit cannot be a function name.