Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 173577

Summary: app-shells/bash: readline file completion does not work with multiple lines
Product: Gentoo Linux Reporter: Brandon Mintern <bmintern>
Component: Current packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: CONFIRMED ---    
Severity: normal CC: kfm, shell-tools
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Brandon Mintern 2007-04-06 16:44:58 UTC
I have discovered that a multi-line echo command which should append to a file will not auto-complete when entering the filename.

e.g.
# echo "dev-lang/io ~*" >> /etc/po<TAB>pa<TAB>k<TAB>
correctly gives
# echo "dev-lang/io ~*" >> /etc/portage/package.keywords

but
# echo "dev-lang/io ~*
> dev-lisp/lush ~*" >> /etc/po<TAB>
does not auto-complete.

Reproducible: Always

Steps to Reproduce:
1. Type an echo command with a multi-line string, and attempt to pipe the output to an existing file...
2. Being sure to enter the filename using bash-completion.
Actual Results:  
Tab-completion failed.

Expected Results:  
Tab completion should have worked as it does with a single-line command.

# emerge -pv bash-completion

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] app-shells/bash-completion-20050121-r10
Comment 1 Mike Kelly (RETIRED) gentoo-dev 2007-05-06 22:56:30 UTC
Hi, what version of app-shells/bash are you using?
Comment 2 Brandon Mintern 2007-05-06 23:46:51 UTC
(In reply to comment #1)
> Hi, what version of app-shells/bash are you using?
> 

$ esearch bash
[snip]
*  app-shells/bash
      Latest version available: 3.1_p17
      Latest version installed: 3.1_p17
[snip]
Comment 3 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-02-20 14:05:26 UTC
Hi,
This is not actually a bash-completion problem at all. I suspect it will never work that way you want it, but maybe it is a readline issue? Just a guess.

@base-system: Is this even possible to fix or valid to report upstream?
Comment 4 SpanKY gentoo-dev 2012-11-05 16:19:19 UTC
wouldn't hurt to post to the bug-bash list and see what they have to say
Comment 5 kfm 2024-03-03 23:04:54 UTC
This happens because readline does not react to the terminating quote issued in response to a PS2 prompt until the line containing it has been entered. Here is a workaround.

# echo "dev-lang/io ~*
> dev-lisp/lush ~*\
" >> /etc/po<TAB>

The use of cat, followed by ^D to signify EOF, is likely simpler at that point.

If still interested in pursuing it, the OP may issue enhancement requests at either https://savannah.gnu.org/support/?group=bash, https://lists.gnu.org/mailman/listinfo/bug-bash or by emailing Chet Ramey directly.
Comment 6 kfm 2024-03-03 23:09:42 UTC
I bungled up the formatting of the previous command. Essentially, the workaround is to enter the terminating double quote, followed by a backslash then enter. The redirection can then be specified and completed as part of the final input line.

Another way would be to position the redirection operator and completed path prior to the echo command. It doesn't have to be at the end.