You are not logged in.
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
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
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
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
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
$ 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
If it is from the bash-completion package /usr/share/bash-completion/completions/scp (which is a symbolic link to the ssh script)
Offline
@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
@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
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
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
--norc also omits the global /etc/bash.bashrc
Online
Well yes, the idea was to not having to do anything and still use nullglob.
Offline
Sorry, I just meant to address his confusion in post #10
Online
Ah, clear;-) but, yes it does..
Offline
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
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
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
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
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
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
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
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