Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why does bash do this? (filename completion w/OLDPWD)

18 views
Skip to first unread message

Kenny McCormack

unread,
Jun 29, 2014, 10:41:22 AM6/29/14
to
One thing that has annoyed me for a long time is this:

At the prompt, type in:

$ echo $OLDPWD/somef<tab>

I.e., assume that a file called "somefile" exists in $OLDPWD. When you hit
<tab>, it fills in the "ile", as expected, but it also puts a backslash in
front of the $ sign, so you end up with:

$ echo \$OLDPWD/somefile

which is pretty much useless. I've gotten into the habit of going back and
removing the backslash, but I really wonder what delusion resulted in its
being there. Anyone know?

--
- Since the shootings on Friday, the ultra-defensive [maybe wrongly
- hyphenated, but that would be fitting] Roy "News" LIEberman has posted
- at least 90 times, and almost every single post is about his obsessive
- knee-jerk loonball [wacko] gun politics. How much longer before the
- authorities [police] finally disable the trip wires and confiscate the
- arsenal in his St. Louie hovel?

So true. So true.

Kaz Kylheku

unread,
Jun 29, 2014, 11:13:59 AM6/29/14
to
On 2014-06-29, Kenny McCormack <gaz...@shell.xmission.com> wrote:
> One thing that has annoyed me for a long time is this:
>
> At the prompt, type in:
>
> $ echo $OLDPWD/somef<tab>
>
> I.e., assume that a file called "somefile" exists in $OLDPWD. When you hit
><tab>, it fills in the "ile", as expected, but it also puts a backslash in
> front of the $ sign, so you end up with:
>
> $ echo \$OLDPWD/somefile

Cannot reproduce.

In Bash "3.2.29(1)-release" on a Debian box, the variable is removed and replaced with
its expansion.

In Bash "4.2.25(1)-release" on an Ubuntu box, the variable stays unexpanded,
and no dollar sign is added.

> which is pretty much useless. I've gotten into the habit of going back and
> removing the backslash, but I really wonder what delusion resulted in its
> being there. Anyone know?

Workaround: if you're in Emacs mode, try M-C-e (i.e. ESC Ctrl-E) to expand the
variable, then do the tab completion.

Kenny McCormack

unread,
Jun 29, 2014, 11:39:47 AM6/29/14
to
In article <201406290...@kylheku.com>,
Kaz Kylheku <k...@kylheku.com> wrote:
>On 2014-06-29, Kenny McCormack <gaz...@shell.xmission.com> wrote:
>> One thing that has annoyed me for a long time is this:
>>
>> At the prompt, type in:
>>
>> $ echo $OLDPWD/somef<tab>
>>
>> I.e., assume that a file called "somefile" exists in $OLDPWD. When you hit
>><tab>, it fills in the "ile", as expected, but it also puts a backslash in
>> front of the $ sign, so you end up with:
>>
>> $ echo \$OLDPWD/somefile
>
>Cannot reproduce.

It does seem to be version-of-bash dependent. Maybe I need to post a
you-tube vid of it happening...

>In Bash "3.2.29(1)-release" on a Debian box, the variable is removed and replaced with
>its expansion.

On MACOSX, with "3.2.48(1)-release", the bad behavior does not happen. As
you say, the variable is expanded out when you hit tab.

>In Bash "4.2.25(1)-release" on an Ubuntu box, the variable stays unexpanded,
>and no dollar sign is added.

(I assume you meant "backslash"...)

On MACOSX, with "4.3.0(1)-release", the bad behavior also does not happen.
The variable stays un-expanded, and you see:

$ echo $OLDPWD/somefile

However, on the Raspberry Pi, with "4.2.37(1)-release", it definitely
*does* happen, as described in the OP.

>> which is pretty much useless. I've gotten into the habit of going back and
>> removing the backslash, but I really wonder what delusion resulted in its
>> being there. Anyone know?
>
>Workaround: if you're in Emacs mode, try M-C-e (i.e. ESC Ctrl-E) to expand the
>variable, then do the tab completion.

I don't do Emacs.

But as usual, workarounds are cheap and plentiful; what I want is for it to
be fixed. Note, BTW, that this bug seems to be alive in the second newest
version to which I have access. In fact, it seems to be OK in 4.2.25 (per
your post) and 4.3.0, but broken in 4.2.37.

Maybe I just need to recompile bash from latest sources on the Pi.

--
One of the best lines I've heard lately:

Obama could cure cancer tomorrow, and the Republicans would be
complaining that he had ruined the pharmaceutical business.

(Heard on Stephanie Miller = but the sad thing is that there is an awful lot
of direct truth in it. We've constructed an economy in which eliminating
cancer would be a horrible disaster. There are many other such examples.)

Alessandro Selli

unread,
Jun 29, 2014, 1:06:23 PM6/29/14
to
On 29/06/2014 at 16:41, Kenny McCormack wrote:
> One thing that has annoyed me for a long time is this:
>
> At the prompt, type in:
>
> $ echo $OLDPWD/somef<tab>
>
> I.e., assume that a file called "somefile" exists in $OLDPWD. When you hit
> <tab>, it fills in the "ile", as expected, but it also puts a backslash in
> front of the $ sign, so you end up with:
>
> $ echo \$OLDPWD/somefile
>
> which is pretty much useless. I've gotten into the habit of going back and
> removing the backslash, but I really wonder what delusion resulted in its
> being there. Anyone know?

It must have to do with the settings of the complete built-in command,
but I cannot search into the matter further right now. I can only see that
Fedora20 has this file /etc/profile.d/bash_completion.sh that customizes it:

alessandro@hal9k ~ $ cat /etc/profile.d/bash_completion.sh
# Check for interactive bash and that we haven't already been sourced.
[ -z "$BASH_VERSION" -o -z "$PS1" -o -n "$BASH_COMPLETION_COMPAT_DIR" ] &&
return

# Check for recent enough version of bash.
bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}
if [ $bmajor -gt 4 ] || [ $bmajor -eq 4 -a $bminor -ge 1 ]; then
[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] && \
. "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion"
if shopt -q progcomp && [ -r /usr/share/bash-completion/bash_completion
]; then
# Source completion code.
. /usr/share/bash-completion/bash_completion
fi
fi
unset bash bmajor bminor
alessandro@hal9k ~ $


Regards,


--
Alessandro Selli http://alessandro.route-add.net
AVVERTENZA: i messaggi inviati a "trappola" non mi arriveranno.
WARNING: messages sent to "trappola" will never reach me.

Underactive Moth

unread,
Jun 29, 2014, 2:46:23 PM6/29/14
to
Kenny McCormack <gaz...@shell.xmission.com> wrote:
> In article <201406290...@kylheku.com>,
> Kaz Kylheku <k...@kylheku.com> wrote:
> >On 2014-06-29, Kenny McCormack <gaz...@shell.xmission.com> wrote:
> >> One thing that has annoyed me for a long time is this:
> >>
> >> At the prompt, type in:
> >>
> >> $ echo $OLDPWD/somef<tab>
> >>
> >> I.e., assume that a file called "somefile" exists in $OLDPWD. When you hit
> >><tab>, it fills in the "ile", as expected, but it also puts a backslash in
> >> front of the $ sign, so you end up with:
> >>
> >> $ echo \$OLDPWD/somefile
> >
> >Cannot reproduce.
>
> It does seem to be version-of-bash dependent. Maybe I need to post a
> you-tube vid of it happening...

> However, on the Raspberry Pi, with "4.2.37(1)-release", it definitely
> *does* happen, as described in the OP.

You need to remove Debian's most pointless package,
bash-completion.

Kenny McCormack

unread,
Jun 29, 2014, 2:56:05 PM6/29/14
to
In article <lopmtv$bn7$2...@dont-email.me>,
Underactive Moth <underac...@gmail.com> wrote:
...
>> However, on the Raspberry Pi, with "4.2.37(1)-release", it definitely
>> *does* happen, as described in the OP.
>
>You need to remove Debian's most pointless package,
>bash-completion.

Interesting. That sounds promising. Can you say any more about what that
package does? What problem is it intended to solve? Why do you think it
is bad? Why do other people, presumably, think it is good?

BTW, it doesn't seem to be a problem on Ubuntu systems. Did the Ubuntu
people figure it out and remove it from the Debian base?

It sounds like the Raspbian people should follow their lead.

--
To most Christians, the Bible is like a software license. Nobody
actually reads it. They just scroll to the bottom and click "I agree."

- author unknown -

Alessandro Selli

unread,
Jun 29, 2014, 4:48:21 PM6/29/14
to
On 29/06/2014 at 20:46, Underactive Moth wrote:

[...]

> You need to remove Debian's most pointless package,
> bash-completion.

Fedora behaves just like Debian in this regard.

Christian Weisgerber

unread,
Jun 29, 2014, 4:39:43 PM6/29/14
to
On 2014-06-29, Kenny McCormack <gaz...@shell.xmission.com> wrote:

> $ echo $OLDPWD/somef<tab>
> $ echo \$OLDPWD/somefile

Odd indeed. I just tried this with the latest bash 4.3.18. It
doesn't happen with "somefile", but it does happen with something
like "another file" (yes, space).

> I really wonder what delusion resulted in its being there. Anyone know?

Clearly some overzealous attempt to quote characters that result
from completion and require quoting. I don't think if you had a
file "some$file" that you would complain over a completion like
this:

$ echo some<tab>
$ echo some\$file

--
Christian "naddy" Weisgerber na...@mips.inka.de
0 new messages