Re:Explainshell – match command-line arguments to their help...
by mtdewcmu on Thursday August 29, 2013 @09:20PM
(#6299691)
The occasional tool, like find, is beyond the capabilities of a DFA, because it's based on a context free grammar (e.g., it counts parentheses).
[ Parent
| on HN ]
Re:Explainshell – match command-line arguments to their help...
by JelteF on Friday August 30, 2013 @06:40AM
(#6301046)
True for official regular expressions, but not for the ones used in most programming languages. http://nikic.github.io/2012/06/15/The-true-power-of-regular-...
Re:Explainshell – match command-line arguments to their help...
by mtdewcmu on Friday August 30, 2013 @03:55PM
(#6303839)
True. Perl-style regexes have grown capabilities far beyond regexes in formal language theory. Note that I was referring to DFAs.
Re:Explainshell – match command-line arguments to their help...
by idank on Friday August 30, 2013 @04:18AM
(#6300743)
This regex is the one I used to extract options from man pages, not to parse the command line (which is simply a wrapper around Python's shlex).
Re:Explainshell – match command-line arguments to their help...
by mtdewcmu on Friday August 30, 2013 @04:11PM
(#6303921)
I see. I started doing almost the exact same thing at one time. My goal was to create autocomplete rules. I think I used the output from the tool's --help or -? rather than manpages, and I would have been using awk and sed, since I never learned Python.
Bash autocomplete specifications are messy, but you can sidestep a lot of the mess. You're allowed to run an arbitrary command to generate the completion list. I was envisioning some kind of standard option grammar that the autocomplete program would interpret for a given tool. The grammar would be partly generated automatically, but would likely need hand-tuning.