@@ -39,18 +39,22 @@ documentation, changelog and configuration walkthroughs.
39
39
const (
40
40
bashCompletionFunc = `
41
41
__rclone_custom_func() {
42
- if [[ ${#COMPREPLY[@]} -eq 0 && :$SHELLOPTS: != *:posix:* ]]; then
42
+ if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
43
43
local cur cword prev words
44
44
if declare -F _init_completion > /dev/null; then
45
45
_init_completion -n : || return
46
46
else
47
47
__rclone_init_completion -n : || return
48
48
fi
49
49
if [[ $cur != *:* ]]; then
50
+ local ifs=$IFS
51
+ IFS=$'\n'
52
+ local remotes=($(command rclone listremotes))
53
+ IFS=$ifs
50
54
local remote
51
- while IFS= read -r remote ; do
55
+ for remote in "${remotes[@]}" ; do
52
56
[[ $remote != $cur* ]] || COMPREPLY+=("$remote")
53
- done < <(command rclone listremotes)
57
+ done
54
58
if [[ ${COMPREPLY[@]} ]]; then
55
59
local paths=("$cur"*)
56
60
[[ ! -f ${paths[0]} ]] || COMPREPLY+=("${paths[@]}")
@@ -62,11 +66,15 @@ __rclone_custom_func() {
62
66
else
63
67
local prefix=
64
68
fi
69
+ local ifs=$IFS
70
+ IFS=$'\n'
71
+ local lines=($(rclone lsf "${cur%%:*}:$prefix" 2>/dev/null))
72
+ IFS=$ifs
65
73
local line
66
- while IFS= read -r line ; do
74
+ for line in "${lines[@]}" ; do
67
75
local reply=${prefix:+$prefix/}$line
68
76
[[ $reply != $path* ]] || COMPREPLY+=("$reply")
69
- done < <(rclone lsf "${cur%%:*}:$prefix" 2>/dev/null)
77
+ done
70
78
[[ ! ${COMPREPLY[@]} || $(type -t compopt) != builtin ]] || compopt -o filenames
71
79
fi
72
80
[[ ! ${COMPREPLY[@]} || $(type -t compopt) != builtin ]] || compopt -o nospace
0 commit comments