About touch *
#9516
-
I just found out something that makes me wonder. When I run Is this difference in behavior expected? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It is, yes. See https://fishshell.com/docs/current/faq.html#my-command-prints-no-matches-for-wildcard-but-works-in-bash. The short of it is this: In bash, the We consider the bash default behavior to be a mistake, and it requires some fairly awkward workarounds. In your specific case, run: rm '*'
touch foo and now try |
Beta Was this translation helpful? Give feedback.
It is, yes. See https://fishshell.com/docs/current/faq.html#my-command-prints-no-matches-for-wildcard-but-works-in-bash.
The short of it is this: In bash, the
*
is also considered to be a wildcard, except when it doesn't match bash just passes it on literally. In fish, if it doesn't match it errors out and doesn't run the command. This is like bash with the "failglob" option.We consider the bash default behavior to be a mistake, and it requires some fairly awkward workarounds.
In your specific case, run:
rm '*' touch foo
and now try
touch *
again in bash - it will no longer create a file called*
, because now "foo" matches!