3

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?

1 Answer 1

3

Use:

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

instead; it does the same thing.

4
  • Great! This works. Curious why backticks don't though. Any ideas? Commented Sep 10, 2010 at 11:32
  • Maybe because backticks are old-style now, but I sill prefer them.
    – cYrus
    Commented Sep 10, 2010 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. Commented Sep 10, 2010 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. Commented Sep 10, 2010 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .