$variable broken with tab completion into \$variable
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I think it is tab completion, not CDPATH.
I cannot reproduce your behavior on my system, $setup stays unchanged if tab completion is used.
My settings:
Code:
$ echo $BASH_VERSION
5.0.17(1)-release
$ set | grep -i complet
BASHOPTS=checkwinsize:cmdhist:complete_fullquote:expand_aliases:extquote:force_fignore:globasciiranges:histappend:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
What are your settings?
Perhaps you have a buggy completion code in /etc/profile.d/*comp*.sh or your bash version has a bug.
by the way, it is an interesting question, you might want to take $ as it is ($ char) or as a beginning of a variable. How can bash decide which one do you mean? What to do if you have both $short and $shortcut variables (for example)? What to do if you have no such variable set or contains something "strange"? Do you think bash completion should check everything? How long will it take?
It does the usual expansion:
type \$ if you want a literal $
type $sh
and hit tab, then it will expand to the first hit $short, hit tab again and it will show the matches $short and $shortcut
type c
and hit tab, and it will expand to $shortcut
It does the usual expansion:
type \$ if you want a literal $
type $sh
and hit tab, then it will expand to the first hit $short, hit tab again and it will show the matches $short and $shortcut
type c
and hit tab, and it will expand to $shortcut
All of my custom variables start with $d and tab expansion works fine with the variables only, for example:
The problem occurs when I want to tab complete subdirs:
Code:
$ cd $dn/
<tab>
$ cd \$dn/
I bet it has to do with "extglob" in my "set"; "globbing" has been suggested for other issues of mine in the past. I will attempt to remove that with caution.
That's awesome!! I don't see anything that obviously matches my issue. Here's mine, please share yours if you don't mind. I can use it to practice diffing. I will also diff it with my next distro.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Quote:
Originally Posted by disk_bearing
In bash when I press tab,
Code:
cd $shortcut/s
becomes
Code:
cd \$shortcut/subdir
and the slash added before $ breaks the command.
You're not alone. I've seen the same thing:
Code:
$ TGT=`pwd`
$ cd someplace else
$ cp file $TGT
works OK but often recalling it and trying to change it, the environment variable has been prefixed with the escape character and, of course, the command fails until I delete it. I figure it's a weird bash thing -- maybe version-dependent. I see this happening on openSUSE where I spend most of the day; I'll have to confirm if the same thing happens on Slackware and/or Raspbian.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.