Summary: | app-shells/bash-completion-2.9: /usr/share/bash-completion/completions/rsync: line 16: syntax error near unexpected token `(' | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Albert W. Hopkins <marduk> |
Component: | Current packages | Assignee: | Michał Górny <mgorny> |
Status: | RESOLVED INVALID | ||
Severity: | normal | CC: | jstein, shell-tools |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Albert W. Hopkins
2019-04-28 17:04:29 UTC
I'm afraid I can't reproduce this. Completing 'rsync' seems to work fine for me. Could you be more specific on how you reproduce it? In particular, can you reproduce it outside gnome-shell? (In reply to Michał Górny from comment #1) > I'm afraid I can't reproduce this. Completing 'rsync' seems to work fine > for me. > > Could you be more specific on how you reproduce it? In particular, can you > reproduce it outside gnome-shell? Ok I have a little more information this time. This is a regression, but possibly not a bug per-se. I'm not really sure what's going on, but... So in my interactive bash shells I have "cp" aliased to rsync as rsync is nearly arg-compatible with /bin/cp and I like to be able to `cp somefile host:` for example. Given that and that I also like to be able to do completion on "cp" as if it were rsync, I have the following custom bash-completion: ``` # custom.sh . /usr/share/bash-completion/completions/rsync complete -o nospace -F _rsync cp ``` This has worked for me for many years, and still does in my interactive bash prompts even with bash-completion-2.9. However somehow gdm is having an issue with it: ``` Apr 28 12:08:19 lighthouse /usr/libexec/gdm-wayland-session[12447]: /usr/share/bash-completion/completions/rsync: line 16: ` --link-dest|-!(-*)T)' Apr 28 12:08:19 lighthouse gnome-keyring-ssh.desktop[12484]: SSH_AUTH_SOCK=/run/user/1000/keyring/ssh ``` Oddly this only happens with I log in to GNOME on X11. When I log into GNOME on Wayland I don't get the error. Also when I open a bash my custom completion for "cp" still works. Even when I manually run the custom completion script I get no such error. Update: Ok this works: ``` $ echo $SHELL /bin/bash $ source ./custom.sh ``` However this results in the same syntax error: ``` bash ./custom.sh ``` I'm actually sourcing it from my .bash_profile though, so I don't know how/why it's different. Either way I would think that both would be valid or both would be invalid. Also: ``` $ . /usr/share/bash-completion/completions/rsync $ bash /usr/share/bash-completion/completions/rsync /usr/share/bash-completion/completions/rsync: line 16: syntax error near unexpected token `(' /usr/share/bash-completion/completions/rsync: line 16: ` --link-dest|-!(-*)T)' ``` With bash-completion-0.28 both variations work. Though I'm still not sure how/why gdm is trying to "bash" it. ``` $ diff -u rsync.old /usr/share/bash-completion/completions/rsync --- rsync.old 2019-04-28 12:33:54.573926461 -0700 +++ /usr/share/bash-completion/completions/rsync 2019-04-28 05:53:20.272934119 -0700 @@ -12,20 +12,20 @@ _filedir return ;; - -T|--temp-dir|--compare-dest|--backup-dir|--partial-dir|--copy-dest|\ - --link-dest) + --temp-dir|--compare-dest|--backup-dir|--partial-dir|--copy-dest|\ + --link-dest|-!(-*)T) compopt +o nospace _filedir -d return ;; - -e|--rsh) + --rsh|-!(-*)e) compopt +o nospace - COMPREPLY=( $( compgen -W 'rsh ssh' -- "$cur" ) ) + COMPREPLY=( $(compgen -W 'rsh ssh' -- "$cur") ) return ;; --compress-level) compopt +o nospace - COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) return ;; esac @@ -36,7 +36,7 @@ case $cur in -*) - COMPREPLY=( $( compgen -W '--verbose --quiet --no-motd --checksum + COMPREPLY=( $(compgen -W '--verbose --quiet --no-motd --checksum --archive --recursive --relative --no-implied-dirs --backup --backup-dir= --suffix= --update --inplace --append --append-verify --dirs --old-dirs --links --copy-links @@ -61,7 +61,7 @@ --out-format= --log-file= --log-file-format= --password-file= --list-only --bwlimit= --write-batch= --only-write-batch= --read-batch= --protocol= --iconv= --ipv4 --ipv6 --version - --help --daemon --config= --no-detach' -- "$cur" ) ) + --help --daemon --config= --no-detach' -- "$cur") ) [[ $COMPREPLY == *= ]] || compopt +o nospace ;; *:*) ``` Ok, so I'm thinking the problem is that the completion file relies on some bash options (extglob?) that are enabled by one of the base completion scripts. When you run it this particular way, the script is loaded too early (i.e. before main completion scripts) and fails because of incompatible options. Indeed, if I do: $ shopt -u extglob $ . /usr/share/bash-completion/completions/rsync I get the syntax error. I think you can try adding 'shopt -s extglob' on top of custom.sh. (In reply to Michał Górny from comment #6) [...] > > I think you can try adding 'shopt -s extglob' on top of custom.sh. That fixed it, thanks. So I guess we can close this out as it's less of a bug and more of a learning experience :) |