Unwanted backslash before dolar sign in environment variable

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read how to get help
Post Reply
Cenko
Level 1
Level 1
Posts: 5
Joined: Fri Sep 09, 2011 6:12 pm

Unwanted backslash before dolar sign in environment variable

Post by Cenko » Wed Nov 23, 2011 9:30 am

Hi,

In Linux mint katya I have the following problem:
I have a folder, defined as environmental variable:

Code: Select all

export MYFOLD="/foo/bar/"
When I want to use tab completetion to go to folder /foo/bar/cenk/, it mess up. I write:

Code: Select all

cd $MYFOLD/
and press tab, it does nothing, when I use ls instead of cd, with tab it changes to the following:

Code: Select all

ls \$MYFOLD/
Why is it happening? I couldn't find it on internet. I had the same thing back in Ubuntu 10.04 too.

User avatar
xenopeek
Level 24
Level 24
Posts: 23126
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Unwanted backslash before dolar sign in environment vari

Post by xenopeek » Wed Nov 23, 2011 12:09 pm

Well, that won't work. Auto-complete is for things you type, it doesn't know that $MYFOLD is a variable it should first expanded (until you press enter and your command is parsed by the shell, because that is when variables are expanded).

Perhaps it can be done in another way, I'm not sure. You could make an alias instead.

Code: Select all

alias foo="cd /foo/bar"
Then you would do it in two steps:

Code: Select all

foo
cd <autocomplete works here as expected>
Image

Cenko
Level 1
Level 1
Posts: 5
Joined: Fri Sep 09, 2011 6:12 pm

Re: Unwanted backslash before dolar sign in environment vari

Post by Cenko » Mon Dec 12, 2011 6:57 am

Hi,

Now I'm in Linux Mint Lisa, and still have the same issue.

In other systems (gentoo or red-hat) i've tried the same and it works. When I press tab after:

Code: Select all

cd $MYFOLD/
it expands it as follows:

Code: Select all

cd /foo/bar/
Probably its somewhere in bash settings but I couldn't find.

User avatar
Anakinholland
Level 3
Level 3
Posts: 145
Joined: Sun Oct 30, 2011 8:09 am

Re: Unwanted backslash before dolar sign in environment vari

Post by Anakinholland » Mon Dec 12, 2011 7:10 am

Apparently it's a bug: http://stackoverflow.com/questions/6418 ... b-complete

Direct link to launchpad.

Maybe you can downgrade to an older version.

Regards,

Anakin
Please Edit your initial post title and add [SOLVED] once your question is resolved.

Cenko
Level 1
Level 1
Posts: 5
Joined: Fri Sep 09, 2011 6:12 pm

Re: Unwanted backslash before dolar sign in environment vari

Post by Cenko » Mon Dec 12, 2011 8:51 am

Thanks Anakinholland, I also found some threads about it.

http://old.nabble.com/bash-tab-variable ... 10234.html

I found a workaround though. when I press CTRL+ALT+e after:

Code: Select all

cd $MYFOLD/
it expands it as I want.
Maybe you can downgrade to an older version.
This seems like the ultimate solution for now. Maybe will try it.

AlbertP
Level 16
Level 16
Posts: 6725
Joined: Sun Jan 30, 2011 12:38 pm
Location: Utrecht, The Netherlands

Re: Unwanted backslash before dolar sign in environment vari

Post by AlbertP » Mon Dec 12, 2011 3:11 pm

You have to use a \ before the $ sign as $ has a special meaning in the terminal. This \ is to make sure that $ is just part of the text in this case. You can put the name between "" quotes to get rid of this.
Registered Linux User #528502
Image
Feel free to correct me if I'm trying to write in Spanish, French or German.

Post Reply

Return to “Other topics”