Add _split_longopt() helper for improved handling of long options that take arguments in both "--foo bar" and "--foo=bar" formats.
This commit is contained in:
parent
a66323a18f
commit
45182e1809
2
CHANGES
2
CHANGES
@ -32,6 +32,8 @@ bash-completion (1.x)
|
|||||||
* Use POSIX compliant arguments to tail in mkisofs completion.
|
* Use POSIX compliant arguments to tail in mkisofs completion.
|
||||||
* Protect various completions from unusual user input by not embedding the
|
* Protect various completions from unusual user input by not embedding the
|
||||||
input in external command arguments.
|
input in external command arguments.
|
||||||
|
* Add _split_longopt() helper for improved handling of long options that
|
||||||
|
take arguments in both "--foo bar" and "--foo=bar" formats.
|
||||||
|
|
||||||
[ Todd Zullinger ]
|
[ Todd Zullinger ]
|
||||||
* Make yum complete on filenames after install, deplist, update and upgrade
|
* Make yum complete on filenames after install, deplist, update and upgrade
|
||||||
|
@ -317,6 +317,23 @@ _filedir()
|
|||||||
COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
|
COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function splits $cur=--foo=bar into $prev=--foo, $cur=bar, making it
|
||||||
|
# easier to support both "--foo bar" and "--foo=bar" style completions.
|
||||||
|
# Returns 0 if current option was split, 1 otherwise.
|
||||||
|
#
|
||||||
|
_split_longopt()
|
||||||
|
{
|
||||||
|
if [[ "$cur" == --?*=* ]]; then
|
||||||
|
# Cut also backslash before '=' in case it ended up there
|
||||||
|
# for some reason.
|
||||||
|
prev="${cur%%?(\\)=*}"
|
||||||
|
cur="${cur#*=}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# This function tries to parse the output of $command --help
|
# This function tries to parse the output of $command --help
|
||||||
#
|
#
|
||||||
_parse_help() {
|
_parse_help() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user