Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 684602 - app-shells/bash-completion-2.9: /usr/share/bash-completion/completions/rsync: line 16: syntax error near unexpected token `('
Summary: app-shells/bash-completion-2.9: /usr/share/bash-completion/completions/rsync:...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Michał Górny
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-28 17:04 UTC by Albert W. Hopkins
Modified: 2019-04-28 21:07 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Albert W. Hopkins 2019-04-28 17:04:29 UTC
Since upgrading to bash-completion-2.9 I get the following error:

```
/usr/share/bash-completion/completions/rsync: line 16: syntax error near unexpected token `('
/usr/share/bash-completion/completions/rsync: line 16: `        --link-dest|-!(-*)T)'
```

It actually causes my gnome-shell session to exit immediately for some reason.  After downgrading to bash-completion-2.8 the problem went away.


```
emerge --info =bash-completion-2.9
Portage 2.3.65 (python 3.6.8-final-0, default/linux/amd64/17.0/no-multilib, gcc-8.3.0, glibc-2.29-r2, 5.1.0-rc6 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.1.0-rc6-x86_64-Intel-R-_Core-TM-_i7-8650U_CPU_@_1.90GHz-with-gentoo-2.6
KiB Mem:    16367444 total,  13994248 free
KiB Swap:   16777212 total,  16777212 free
Timestamp of repository gentoo: Sun, 28 Apr 2019 14:44:12 +0000
Timestamp of repository marduk: Tue, 09 Apr 2019 13:48:24 +0000
sh bash 5.0_p7
ld GNU ld (Gentoo 2.32 p2) 2.32.0
app-shells/bash:          5.0_p7::gentoo
dev-lang/perl:            5.28.2::gentoo
dev-lang/python:          2.7.16::gentoo, 3.6.8::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/sandbox:         2.17::gentoo
sys-devel/binutils:       2.32-r1::gentoo
sys-devel/gcc:            8.3.0-r1::gentoo
sys-devel/gcc-config:     2.0::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.0-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.29-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://blackwidow/portage
    priority: -1000
    sync-rsync-extra-opts:      --exclude .rsync-filter     --info=progress2 
    sync-rsync-verify-metamanifest: False
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24

marduk
    location: /usr/local/portage
    sync-type: rsync
    sync-uri: rsync://blackwidow/local-portage
    masters: gentoo
    priority: 50
    sync-rsync-extra-opts:      --exclude .rsync-filter     --info=progress2 
    sync-rsync-verify-metamanifest: False

Installed sets: @avaya
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA AdobeFlash-11.x Google-TOS google-chrome google-talkplugin"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=native -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=native -pipe"
DISTDIR="/var/portage/distfiles"
EMERGE_DEFAULT_OPTS="         --alphabetical     --autounmask=n     --buildpkg-exclude=sys-kernel/gentoo-sources     --changed-deps=y     --color=n     --jobs=5     --nospinner     --unordered-display     --verbose-conflicts     --with-bdeps=y     --binpkg-changed-deps    --binpkg-respect-use    --buildpkg    --color=y    --getbinpkg    --jobs=3    --keep-going    --oneshot    --quiet-build    --quiet-unmerge-warn    --rebuilt-binaries=y    --with-bdeps=n "
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg cgroup config-protect-if-modified distlocks fixlafiles ipc-sandbox multilib-strict network-sandbox news noinfo notitles parallel-fetch pid-sandbox preserve-libs protect-owned sandbox sfperms skiprocheck strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="/usr/share/doc"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j8 -l8"
PKGDIR="/var/portage/packages"
PORTAGE_BINHOST="http://blackwidow/packages/lighthouse/"
PORTAGE_COMPRESS=""
PORTAGE_COMPRESS_FLAGS=""
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="     --exclude .rsync-filter     --info=progress2 "
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl aes amd64 asm avx avx2 f16c fma3 glamor introspection ipv6 mmx mmxext nls nptl opentype pam pclmul popcnt seccomp split-usr sse sse2 sse3 sse4_1 sse4_2 ssse3 systemd udev unicode urandom utf8 wayland xattr" ABI_X86="64" APACHE2_MODULES="auth_digest authn_core authn_file authz authz_core authz_groupfile authz_host authz_user dav dav_fs dir group_file mime socache_shmcb unixd" APACHE2_MPMS="prefork" CAMERAS="*" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" CURL_SSL="openssl" ELIBC="glibc" FFTOOLS="*" INPUT_DEVICES="libinput" KERNEL="linux" LLVM_TARGETS="X86" NGINX_MODULES_HTTP="auth_basic gzip proxy rewrite uwsgi" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby25" USERLAND="GNU" VIDEO_CARDS="intel i965"
Unset:  CC, CPPFLAGS, CTARGET, CXX, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND
```
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-04-28 18:20:58 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?
Comment 2 Albert W. Hopkins 2019-04-28 19:24:29 UTC
(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.
Comment 3 Albert W. Hopkins 2019-04-28 19:28:18 UTC
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)'
```
Comment 4 Albert W. Hopkins 2019-04-28 19:32:58 UTC
With bash-completion-0.28 both variations work.  Though I'm still not sure how/why gdm is trying to "bash" it.
Comment 5 Albert W. Hopkins 2019-04-28 19:38:00 UTC
```
$ 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
             ;;
         *:*)
```
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-04-28 19:56:50 UTC
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.
Comment 7 Albert W. Hopkins 2019-04-28 20:59:20 UTC
(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 :)