9

On a "standard BASH" does a wildcard inside double-quotes glob? For example:

$ touch abc
$ ls "*abc*"

would that, or wouldn't that work on bash?

I was told Ubuntu shipped with a bash variant that doesn't conform to POSIX or BASH. Is that true?

Matt
  • 767
  • 1
  • 11
  • 18

1 Answers1

8

Short answer: no

Long answer from man bash:

Enclosing characters in double quotes preserves the literal value of all characters within the quotes, with the exception of $, `, \

So:

~$ touch sas
~$ ls *a*
sas
~$ ls "*a*"
ls: cannot access *a*: No such file or directory

Of course when talking about double quotes and asterisks there is another exception: parameter expansion (ie: "$*") ...but that's another history

For the second question: are you asking about dash? dash is a lightweight shell for scripts. In debian, and in ubuntu per extension (as is debian based), is aliased to sh; It's major advantage over bash is its speed, so it is used by default for system scripts; however bash is still available as the interactive shell for users by default

 ~$ ls -l /bin/sh 
lrwxrwxrwx 1 root root 4 2011-04-21 11:54 /bin/sh -> dash
hmontoliu
  • 455
  • 3
  • 6
  • Ah.. Thanks. Yes, I was aware /bin/sh was aliased to `dash`. But anyway, someone I am talking to tells me this works on his Red Hat system [* globs when double quoted--he says the only way to be sure they do not glob is to use single quotes]. Any idea why? – Matt Aug 03 '11 at 21:59
  • No, your friend is completely wrong - double check the quote from man bash I've posted in my answer. – hmontoliu Aug 03 '11 at 22:02
  • I did not say he was my friend :P We were having a disagreement, and him being a "programmer for 11 years" and has a big job, and me who's just been learning from google and stuff, since I disagreed with him, this other person [who is a friend's friend --this other guy was his friend] started talking about how I should not be brushing aside his knowledge, because he, by far, was the most knowledgeable one in the discussion. But thanks! :) – Matt Aug 03 '11 at 22:08