diff options
author | Arthur Williams <taaparthur@gmail.com> | 2021-09-05 15:30:59 -0500 |
---|---|---|
committer | Philip Langdale <github.philipl@overt.org> | 2021-09-05 16:51:38 -0700 |
commit | 6f23aa0d3ee91aec54cf46dd52509d98a41f09f2 (patch) | |
tree | 6c3aebb26eb27cee650a8863a3c8a77bd22f1ade /etc | |
parent | 8aef22e45debedc107917e674072976c55c07f0d (diff) | |
download | mpv-6f23aa0d3ee91aec54cf46dd52509d98a41f09f2.tar.bz2 mpv-6f23aa0d3ee91aec54cf46dd52509d98a41f09f2.tar.xz |
bash completion: Allow completions to work without external functions
If bash_completion wasn't installed, _filedir wouldn't be defined which
led to all filename-based completions to error out. Specifically
autocompletion would fail when a filename was expected and when
bash_completion wasn't installed. Now we fall back to `compgen -f` if
_filedir fails. According to _filedir's comments, compgen doesn't
handle files with spaces well, but it is still better to complete most
files than none.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/mpv.bash-completion | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/etc/mpv.bash-completion b/etc/mpv.bash-completion index 60c1cabd51..f33caf60e0 100644 --- a/etc/mpv.bash-completion +++ b/etc/mpv.bash-completion @@ -34,13 +34,12 @@ _mpv_get_args() declare -a candidates case $type in String) - echo "$doc" | grep -q '\[file\]' - if [ $? -eq 0 ]; then + if echo "$doc" | grep -q '\[file\]' ; then if [ "$cur" = '=' ]; then # Without this, _filedir will try and complete files starting with '=' cur="" fi - _filedir + _filedir 2>/dev/null || COMPREPLY=($(compgen -f)) return 0 else candidates=($(mpv $1=help | grep -v ':' | awk '{print $1;}')) @@ -106,7 +105,7 @@ _mpv() fi ;; *) - _filedir + _filedir 2>/dev/null || COMPREPLY=($(compgen -f)) ;; esac fi |