Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

On RHEL5.2 (bash 2.3.25) I can cd `pwd`/[TAB] and pwd is substituted into my current working directory, using the output of pwd(1).

How can I achieve the same functionality in Ubuntu 9.10 (bash 4.0.33).

I have read previous questions that refer to backticks as being old and deprciated. I didn't know this. I can understand nesting them can be difficult, and I use ${} is scripts, but I would like to be able to evaluate commands interactively in the shell.

share|improve this question
    
That seems broken. TAB is supposed to complete the path/command, NOT perform variable substitution. –  psusi May 19 '11 at 14:04
    
Sounds like something RHEL cooked up special for itself, and likely restricted to pwd. See @Caleb's answer. –  djeikyb May 20 '11 at 6:34
add comment

3 Answers 3

This is a feature not a bug.

Think about the scenario this way: In order to make that completion the shell would have to RUN the command in the backticks. This could cause very serious negative consequences if it was something that wasn't meant to run more than once, that took lots of time to execute, etc.

In order to do expansion, bash needs just a string that is a path, not some program to have to execute in order to get a string to complete. Consider the suggestion to use ./ as path for the present working directory as well advised!

Backticks are not old or deprecated, although the newer $() syntax is generally preferred these days. However in your example, using a command at all is ill-advised. Backticks and command should be used sparingly and only when another syntax isn't possible.

share|improve this answer
add comment

Try

cd ./TAB

instead.

cd $VAR/...
cd $(cmd)/...

don't work for me, either. Maybe you can compare the /etc/bash_completion files.

share|improve this answer
    
./ is a good suggestion, that is the proper way to reference the present working directory. Don't expect $var or $(cmd) expansion to happen on tab, that would actually cause all kinds of other problems. –  Caleb May 20 '11 at 5:43
add comment

There are situations where "$PWD/" is needed instead of "./", so it should not be suggested to always to use "./" instead of "$PWD/". One example is when you do a symbolic link.

Suppose you're in /somefolder. Now you run the following command:

ln -s ./file /target/file

This becomes a broken link. What you really need to do is:

ln -s $PWD/file /target/file

It is very inefficient to type the whole path. This problem is independent from "deprecation" issues as symlink just doesn't work in this way. Thus, I suggest you to file a bug to fix this problem.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.