logoalt Hacker News

chasiltoday at 3:14 AM0 repliesview on HN

"Bash shell scripting is already close to perfect for what it is intended."

It is very difficult to write a parser for any derivative of the POSIX shell. The lex/yacc utilities cannot be used; the lexer and parser must exchange state.

It would be better if the shell was an LR-parsed language with a yacc grammar. The yacc utility is itself in POSIX.2.

Here is a talk about an OCaml implementation of a parser for the POSIX shell:

https://archive.fosdem.org/2018/schedule/event/code_parsing_...

Here is another talk about an Ada parser implementation:

https://archive.fosdem.org/2019/schedule/event/ada_shell/

The language grammar is unfortunate.