Sorry guys I made a mistake here. I was wrong about the idea that only the function keyword allows other characters besides [[:alnum:]_]. The classic syntax allows it as well. The only significant difference is that the classic syntax conflicts with extglob, whereas the function keyword does not. When using a syntax like is_a_number?(){ [[ $1 == +([[:digit:]]) ]]; }, bash reports syntax error near unexpected token '}'. But it doesn't happen when extglob is disabled. I probably misinterpreted it as an exception within the classic syntax itself. I never created specially-named functions other than those having the [X.]f? or [X.]f! format.

Anyway, I still would suggest to have this solution applied. The function keyword allows the difference between the special syntax of bash and the classic or POSIX syntax distinguishable. I also don't think people who write POSIX scripts would want to have their function names also validated with special characters which are only recognized in Bash. So generalizing would be bad idea.

P.S. The classic syntax also conflicts with the assignment syntax, but I don't think anyone would want to use the = character for its high ambiguity risk, so it's not really a significant argument to use here.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.