Unwanted blank after command line <tab> expansion

Ralf Mardorf kde.lists at yahoo.com
Sun Sep 4 11:04:21 UTC 2022


On Sun, 2022-09-04 at 20:01 +1000, Karl Auer wrote:
> On Sun, 2022-09-04 at 11:05 +0200, Ralf Mardorf via ubuntu-users wrote:
> > I haven't tried this and the output is from the Arch Linux, not the
> > Ubuntu manual page:
> 
> Why quote a manual page that may not even be relevant? It's way easier
> for the OP to type "man bash", search for "nospace" and get exactly the
> right information than to use an incomplete cut-and-paste version.
> That's why I recommended doing that.

Hi,

that's what I did, but you didn't in your reply in August, right? I
showed one way to search the manual page. The commands "man" and "grep"
are available by all major distros by default and at least for the given
example, they work equal for all major distros. FWIW if the manual page
of bash already should be inconsistent among different Linux distros or
even among Ubuntu releases, it would be a serious problem.

> > I don't know how to use the "nospace" option.
> 
> Then what was the point of your message?!?

To explain that the OP has got a good reason to repeat his request.

> The "nospace" option is an option to the (bash-internal) "complete"
> command, not to bash itself. I have now tried it out.

If you would have read my mails, then you would know that I already
mentioned the "complete" command. However, in your first reply you
mentioned the manual page and a search term and I tried my best to add
additional input. Indeed, I don't know how to solve the issue, my reply
was just trying to help as good as I can.

> I have a completion script for one of my commands. The fundamental guts
> of it (as with all completion scripts) is a call to the "complete"
> command. As the man page says, the "-o" option is for options to the
> "complete" command.
> 
> My completion script thus has this final line in it:
> 
>    complete -F _totp totp
> 
> - complete is the bash command
> - _totp is a function I wrote that builds
>   a completion list
> - totp is the program that this completion
>   script provides completions for
> 
> Altogether this says "when someone wants completions for the 'totp'
> command, call the '_totp' function to get a complete list, then deliver
> matching completions according to whatever they type".
>  
> If I use my completion script and there is NO match, it drops a list of
> all possible matches and leaves the cursor where it is.
> 
> If I use my completion script and there are some matches, it drops a
> list of them and leaves the cursor at the end of the longest matching
> initial substring.
> 
> If I use my completion script and there is exactly ONE match, it adds
> the remainder of the matching entry to what I have already typed, and
> adds a space. This is what the OP did not want. I do not know if this
> is new behaviour - as far as I recall it has always done that, but my
> memory is notoriously unreliable :-)
> 
> So I modified my completion script to add "-o nospace" before first
> existing option to the "complete" command. The command now looks like
> this:
> 
>    complete -o nospace -F _totp totp
> 
> The behaviour is exactly the same except that when there is exactly ONE
> match, it adds the remainder of the matching entry to what I have
> already typed, and DOES NOT add a space.
> 
> Which I am pretty sure is exactly what the OP wanted to know.

I still don't know how to use it, maybe the OP does understand your
explanation. However, in August when the OP asked for the first time,
nobody explained what to do, hence I gave all the reasonable pointers I
can give. This is how brainstorming works. If nobody has got a clue,
then we try to find a solution together.

Regards,
Ralf




More information about the ubuntu-users mailing list