You are not logged in.

#1 2021-01-21 19:59:47

alexispaz
Member
Registered: 2019-05-01
Posts: 23

[SOLVED] scp and rsync tab completion not working (it shows sed help)

If I press [Tab] key after writing a scp or rsync comand like this:

scp server:Folder/[Tab]
rsync server:Folder/[Tab]

I just get the help of sed command followed by a sed error.

Last edited by alexispaz (2021-01-28 16:21:40)

Offline

#2 2021-01-21 22:34:46

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

sed? don't you mean scp? Show the error!
Anyway, is your key added, if you use a key?
Tab completion on remote servers works fine here..

Offline

#3 2021-01-22 14:24:37

alexispaz
Member
Registered: 2019-05-01
Posts: 23

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Yes, sed. Quite strange. Sorry, I forgot to post the error. Bash completion pressing [Tab] for any other commands works well. Here you have:

$ scp server:sed: option requires an argument -- 'e'
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
      --debug
                 annotate program execution
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  --follow-symlinks
                 follow symlinks when processing in place
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if SUFFIX supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  --posix
                 disable all GNU extensions.
  -E, -r, --regexp-extended
                 use extended regular expressions in the script
                 (for portability use POSIX -E).
  -s, --separate
                 consider files as separate rather than as a single,
                 continuous long stream.
      --sandbox
                 operate in sandbox mode (disable e/r/w commands).
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
  -z, --null-data
                 separate lines by NUL characters
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
sed: -e expression #1, char 1: unknown command: `-'

Offline

#4 2021-01-22 15:37:14

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Smells like a bug in the autocomplete script - or a bad sed alias…

type sed

Maybe a weird string in the actual "server:Folder/" token?

Online

#5 2021-01-22 19:11:26

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Hmm, does it also happen with rsync command only, local or remote.
It would be easier to pinpoint the place it's happening.
I mean if it happens if you scp to different servers the cause is most likely local - unless all you servers are the same and use the same configs(unlikely)
I'm with seth and you should check what he mentions in the first place.

Offline

#6 2021-01-23 19:55:20

alexispaz
Member
Registered: 2019-05-01
Posts: 23

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

$ type sed
sed is /usr/bin/sed

It happens after adding a remote server name, with any server name or any folder. Even with not folder at all. So I think it is local.
Furthemore, If I try from another computer to the same servers the issue does not occurs.

Where should I check the autocomplete scripts to see if they are corrupt?

Offline

#7 2021-01-23 20:02:29

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

If it is from the bash-completion package  /usr/share/bash-completion/completions/scp (which is a symbolic link to the ssh script)

Offline

#8 2021-01-24 17:28:40

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

@loqs, I don't have that link.. but even so wouldn't it be more logic the problem is in bashrc or a profile(maybe).
My first look would be in the bashrc.

Offline

#9 2021-01-24 17:45:12

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

qinohe wrote:

@loqs, I don't have that link.. but even so wouldn't it be more logic the problem is in bashrc or a profile(maybe).

pacman -Qo /usr/share/bash-completion/completions/scp
/usr/share/bash-completion/completions/scp is owned by bash-completion 2.11-1

True,  anything in the local configuration will override the supplied completion but the supplied completion was using sed so I thought it was worth providing its location.

Offline

#10 2021-01-24 18:43:56

alexispaz
Member
Registered: 2019-05-01
Posts: 23

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Right. Thank you all, I found the issue.

bash-completion files seems OK when comparing with other computers.
When looking into my .bashrc I found the line that trigger the issue:

shopt -s nullglob

Well... I have found that option very useful and I didn't tought it will be a problem to let it on.

However, I can not understand what is wrong. When I do:

bash --norc
shopt -s nullglob
ssh server:[Tab]

It works well. But if I just comment my entire .bashrc file, open a new terminal and do:

shopt -s nullglob
ssh server:[Tab]

It gives the error... ¿?

Offline

#11 2021-01-24 21:01:04

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

I have read that nullglob can break tab completion.

Can you set in your bashrc

setopt nullglob

and then try again, this should delete the pattern instead of giving you an error, haven't tried..
Maybe it's an idea to create an alias for it (shopt -s nullglob) and use it on a per case basis.

Last edited by qinohe (2021-01-24 21:01:55)

Offline

#12 2021-01-24 21:16:52

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

--norc also omits the global /etc/bash.bashrc

Online

#13 2021-01-24 21:38:50

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Well yes, the idea was to not having to do anything and still use nullglob.

Offline

#14 2021-01-24 21:55:15

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Sorry, I just meant to address his confusion in post #10

Online

#15 2021-01-24 22:03:23

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Ah, clear;-) but, yes it does..

Offline

#16 2021-01-25 17:21:59

alexispaz
Member
Registered: 2019-05-01
Posts: 23

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

bash: setopt: command not found

Looking into /etc/bash.bashrc, there is a line to execute the bash_completion script. Thereferor, I can reproduce the error if I do:

bash --norc
shopt -s nullglob
. /usr/share/bash-completion/bash_completion
ssh server:[Tab]

Not sure what is the need of execute this script, because if I do not execute it, I have completion anyway and it works well.

Offline

#17 2021-01-25 21:13:51

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Ah  yes, zsh user here sorry about that setopt.
About '/etc/bash.bashrc' , that's your global rc..
If your completion works now you should be okay.

Offline

#18 2021-01-25 21:33:40

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Not sure what is the need of execute this script

Does autocompletion work at all in bash w/o sourcing /usr/share/bash-completion/bash_completion ?

A workaround/solution could be to explicitly toggle nullglob in the offending completion script functions in /usr/share/bash-completion/completions/scp
That doesn't mean it won't break other scripts likewise.

Online

#19 2021-01-25 21:49:44

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Obviously there is some strange option set and my bet is that strange option is nullglob in the rc.
I also suggested to use nullglob on a per case basis - in a script, an alias when needed -, which I personally find better than to put it in your rc.

Offline

#20 2021-01-25 21:53:26

seth
Member
Registered: 2012-09-03
Posts: 49,972

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

my bet is that strange option is nullglob in the rc

He already confirmed that in post #10

which I personally find better than to put it in your rc

My assumption would be that he wants that behavior in the interactive shell.

Online

#21 2021-01-25 23:38:00

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

seth wrote:

My assumption would be that he wants that behavior in the interactive shell.

Than he also needs to deal with it's potentially bad behavior.

Offline

#22 2021-01-27 15:24:37

alexispaz
Member
Registered: 2019-05-01
Posts: 23

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

Right, I wanted to have nullglob always on. But that is fine, I will used per case basis as qinohe suggest.

About the need of execute the script, sorry for that, I missunderstood its function.
I have read the wiki and now I understand that it just gives an extension to native completion.

So, to resume:

bash --norc --noprofile
shopt -s nullglob

ech[tab]   ;#...work
ls [tab]   ;#...work
ssh server:[tab]   ;#...work
git cl[tab]   ;#...no work

. /usr/share/bash-completion/bash_completion

ech[tab]   ;#...work
ls [tab]   ;#...work
ssh server:[tab]   ;#... shows sed help
git cl[tab]   ;#...work

Should I mark this as solved?

Offline

#23 2021-01-27 16:51:41

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] scp and rsync tab completion not working (it shows sed help)

If you are happy with the result.. than yes, you can mark this thread solved.
Have you ever considered switching shells?
You could have a look at zsh and see if that is something for you!

edit: FYI, I'm a zsh user myself and your 4 examples(scp not ssh) work fine here.
With or without 'setopt nullglob'

Last edited by qinohe (2021-01-27 20:10:14)

Offline

Board footer

Powered by FluxBB