rclone: rclone genautocomplete has problems with Bash
What is the problem you are having with rclone?
The file spawned by rclone genautocomplete generates this error when I login as root:
10:20:15 [brandizi@brandizmac ~]$ su - root
Password:
-sh: /usr/local/etc/bash_completion.d/rclone: line 266: syntax error near unexpected token `<'
-sh: /usr/local/etc/bash_completion.d/rclone: line 266: ` done < <(command rclone listremotes)'
10:20:18 [root@brandizmac ~]#
And rclone autocompletion fails to work after this (unsurprisingly).
This only happens when I login as root, all other users are fine.
What is your rclone version (output from rclone version)
14:47:13 [root@brandizmac ~]# rclone -V
rclone v1.48.0
- os/arch: darwin/amd64
- go version: go1.12.6
I have rclone installed via Homebrew. Initially I filed this same issue to them, cause I believed they are the ones adding Bash autocompletion.
Which OS you are using and how many bits (eg Windows 7, 64 bit)
14:52:44 [root@brandizmac ~]# sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G87
14:53:24 [root@brandizmac ~]#
Which cloud storage system are you using? (eg Google Drive)
OneDrive, but not relevant hereby.
The command you were trying to run (eg rclone copy /tmp remote:tmp)
See above.
A log from the command with the -vv flag (eg output from rclone -vv copy /tmp remote:tmp)
See above.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (16 by maintainers)
Commits related to this issue
- Fix 'compopt: command not found' on autocomplete on macOS As reported in #3489. — committed to rclone/rclone by sgtpep 5 years ago
- Disable __rclone_custom_func if posix mode is on A workaround for #3489. Code in `__rclone_custom_func` relies on process substitutions `<(...)` to preserve changes of variables within `while` bodies... — committed to rclone/rclone by sgtpep 5 years ago
- cmd: make autocomplete compatible with bash's posix mode #3489 — committed to rclone/rclone by sgtpep 5 years ago
Thank @sgtpep not me 😃 Thank you!
@ncw My patch will eliminate the issue of
compoptnot being found on vanilla macOSbashthat was reported by @marco-brandizi as:So, I think, it worth being merged, although the issue is not fatal and doesn’t break the autocomplete. Sorry for not providing it as a proper PR, didn’t have time for that.
The main issue of this ticket is that autocomplete is defunct when bash is run under root on vanilla macOS
bashbecause it happened to operate inposixmode for some reason. If I understand @marco-brandizi correctly, it’s not a case forbrew-installedbash.We could debug this by placing
set -xsomewhere on top of bash init files to understand whereset -o posixhappens which enables posix mode for root. Or, we could just disable the whole autocomplete script ifposixoption is set (I could provide a patch for that, if needed.)@marco-brandizi As for operation under root there’s still a way to debug it by adding
set -xright after:in
/usr/local/etc/bash_completion.d/rclone, then restarting bash and trying to perform autocompletion.