Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
824 views
in Technique[技术] by (71.8m points)

readline - Bash variable expansion on tab complete

I'm running Ubuntu 11.04, and I'm seeing some odd behaviour when I try to use tab-completion in bash on a path that starts with a variable. If I've got TOP=/scratch, and I try to tab-complete:

cd $TOP/foo

it changes to:

cd $TOP/foo

I'd prefer it to complete to: cd $TOP/foobar or cd /scratch/foobar but I'd settle for it just not changing the line and requiring me to un-escape the $.

Does anyone know where in bash/readline I should look to fix this?

question from:https://stackoverflow.com/questions/6418493/bash-variable-expansion-on-tab-complete

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Found the bug report, please register (if not already registered) and add yourself to the 'people affected' list, I just did:

https://bugs.launchpad.net/ubuntu/+source/bash/+bug/778627

Workarounds

Try enabling direxpand or cdable_vars:

shopt -s direxpand
# or
shopt -s cdable_vars

Apparently EscTab might be a workaround:

I haven't found a proper solution to this, but there's a workaround. The escaping of environment variables can be disabled by pressing Esc followed by tab.

# cd $SO + [Esc] + [Tab]
# cd $SOME_DIR

Confirm that as a bug! I just confirmed that the same thing works on

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 10.10
Release:        10.10
Codename:       maverick

I get broken behaviour on (up-to-date) natty:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.04
Release:    11.04
Codename:   natty

Although I must add that I do not the slash escaped, but the path (while valid, existing, accessible and readable) is not getting expanded.

Info: https://help.ubuntu.com/community/ReportingBugs


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...