I'm on Ubuntu 10.04 and I've ran into a little bit of a snag with bash completions within backticks. Here's an example to illustrate:

I save streaming URL:s to my radio-stations in text files, and I usually start listening by typing

$ mplayer `cat ~/stations/some.fm`

It would be great if I could use tab completion at:

$ mplayer `cat ~/stations/<tab>

In this case, however, the tab completion doesn't seem to match files, only directories. So I get

$ mplayer `cat ~/stations/<tab>
subdir1       subdir2
$ mplayer `cat ~/stations/

But no files! A workaround is to use

$ cat ~/stations/some.fm | xargs mplayer

In this case tab completion works, but I would prefer to use the backtick version. Not for this example alone, but this bit me in many other situations as well.

Does anyone here know how to fix this / where the filter is defined?



$ mplayer $(cat ~/stations/<tab>

instead; it does the same thing.

| improve this answer | |
  • Great! This works. Curious why backticks don't though. Any ideas? – Alexander Torstling Sep 10 '10 at 11:32
  • Maybe because backticks are old-style now, but I sill prefer them. – cYrus Sep 10 '10 at 12:45
  • @you both: Yes, the reason is because the backticks are old-school and $() is the new backtick. But, as an old fart, I also prefer backticks. – Janne Pikkarainen Sep 10 '10 at 13:02
  • Backticks aren't necessarily old-school (even sh supports $()); the problem is that it's hard to know when it's a opening or closing one. Nesting is a hell. – user1686 Sep 10 '10 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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