Comment 3 for bug 1167533

Revision history for this message
Peter Cordes (peter-cordes) wrote :

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.
 -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.

I'll submit this upstream, too