Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • I think this is because unquoted text undergoes Word Expansions while variable undergoes Parameter Expansion. If a variable is unquoted, it then undergoes Pathname Expansion. However I am still not sure if it will perform Quote Removal. It does in case (C). But it does not in the questioned case. Commented Jan 17, 2024 at 13:17
  • That varies widely with the shell and the version thereof. The POSIX spec has changed (and/or will change) in that regard. You'll find extensive and heated discussions about it in the archives of the POSIX (austin-group-l) mailing list. Commented Jan 17, 2024 at 13:22
  • Use [*] to match a literal * portably when in a glob that is a result of an unquoted expansion. Commented Jan 17, 2024 at 13:23
  • See also austingroupbugs.net/view.php?id=1234#c4564 Commented Jan 17, 2024 at 13:28
  • the first two quotes you have, the ones above the horizontal line, discuss how quotes work. That's not relevant for the behavior of the glob, since in both cases (with single and with double quotes), the variable ends up containing sec\*et. And when the glob is expanded later, it doesn't matter how the variable got the value it had. (You could have filled it with e.g. read instead of a regular assignment.) Commented Jan 17, 2024 at 18:29