This question is loosely related to one of my previous ones. TL;DR from muru's answer is that characters in function name have to be on Portable Character Set in order to be valid for a function name. Problem is that space is on the list (the <space>
or <U0020>
character), which is why I'm confused as to why I can't do this:
$ $' '(){ echo "Hullo";}
bash: `' '': not a valid identifier
$ hello$' 'world(){ echo "hi";}
bash: `hello' 'world': not a valid identifier
With other shells:
$ mksh -c '\ (){ echo "Hello";} '
mksh: : invalid function name
$ ksh -c '\ (){ echo "Hello";} '
ksh: : invalid function name
$ dash -c '\ (){ echo "Hello";} '
dash: 1: Syntax error: Bad function name
mksh -c '1(){ …;}'
from your other question worked, did you try this withmksh
too? – dessert Dec 17 '17 at 08:21mksh -c '1(){ …;}'
from last question in interactivemksh
, which works, so that impliesmksh
being not entirely POSIX compliant in function declaration aspect. I wonder if that's something worth reporting to developers. – Sergiy Kolodyazhnyy Dec 17 '17 at 08:36set -o posix
(see the hilarious FAQ at the end of the manual!) – dessert Dec 17 '17 at 09:081(){ echo "hi"; }
works even in posix mode :/ – Sergiy Kolodyazhnyy Dec 17 '17 at 09:11