[Github-comments] [geany/geany] Enhance detection of sh functions (#662)

konsolebox notifications at xxxxx
Thu Mar 22 09:37:07 UTC 2018


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 or view it on GitHub:
https://github.com/geany/geany/pull/662#issuecomment-375234385
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20180322/b60dd0ee/attachment.html>


More information about the Github-comments mailing list