echo ' -r, --recursive like --directories=recurse' | sed -ne 's/\([^-]\|-[^-]\)*\(--[-A-Za-z0-9]\{1,\}=\{0,1\}\).*/\2/p'
--recursive
using \([^-]\|-[^-]\)* instead of .* at the front of the pattern makes the greedy match at the front stop at the first --. If there are commands that use -- as formatting in their --help output, then this won't work, e.g.
-r -- equivalent to --recursive
but otherwise this should be good. It's pretty much standard to list the actual options early in a line, rather than
like --directories=recurse -r, --recursive
This goes in _longopt(), line 1801 of bash_completion.
fixed it:
echo ' -r, --recursive like --directories= recurse' | sed -ne 's/\([^ -]\|-[^ -]\)*\( --[-A-Za- z0-9]\{ 1,\}=\{ 0,1\}\) .*/\2/p'
--recursive
using \([^-]\|-[^-]\)* instead of .* at the front of the pattern makes the greedy match at the front stop at the first --. If there are commands that use -- as formatting in their --help output, then this won't work, e.g. recurse -r, --recursive
-r -- equivalent to --recursive
but otherwise this should be good. It's pretty much standard to list the actual options early in a line, rather than
like --directories=
This goes in _longopt(), line 1801 of bash_completion.
I'll submit this upstream, too