I have a shell bash script wich should pass the star ["*"] wildcard character to an application without using quotation marks. I am reading since hours and always find to use "set -f" inside the callings shell script, but this does nothing. May be I've misunderstood something, but I do not see what.

I am writing a C# app with the mono framework and my call inside bash is like this:

set -f
mono app.exe "$@"

My shell script named "runit" will be used like this:

runit *

Can someone probably shed some light on this? I even tried to output the active shell options from this script, but nothing is shown.



set -f
mono app.exe "$@"

set -f has no effect because the double-quoted argument array ( "$@" ) undergoes no further expansions.

If "$@" contains an argument whose value is *, it will get through to mono app.exe unchanged.

The problem is, that the shell calling this wrapper script will want to expand the asterisk, as set +f is the default.

You'll need to set -f in this calling shell rather than in the wrapper.

With set +f (default), backslash (\*) is another alternative to quoting ('*' or "*") that you might want to consider.

  • Thanks ! Are shells out there, wich are simpler ?? I started to hate bash. Waht about c-shell ? For my case, I would have to write three programs, instead of one. I shortly read an article from a shell-guru, what all could be made wrong. This was there long, that my consequence was: If nearly everything is wrong, then the sHELL must be wrong :-( What about globally setting "-f" generally for my shell ? – mabra Jun 9 '16 at 0:53
  • dash is simpler, and you can pretty much learn it from its manpage. This globbing part is common to both, however. And yes, as I've already, mentioned, you can set -f in your interactive shell if you don't want globbing. – PSkocik Jun 9 '16 at 1:02
  • After starting to try different shells, I saw something similar in a ZSH discussion. This led me to: >alias runit="set -f; runit" So "runit *" works perfectly for the moment. – mabra Jun 9 '16 at 5:19
  • 2
    Disabling globbing will cause more problems than it solves. Unix programs generally don't expand wildcards themselves, they rely on the shell to do it for them (with globbing). Using dash as an interactive shell is a terrible idea - it has none of the usability features like command-line history recall & editing. BTW, if nearly everything seems wrong, it's most likely that there are one or more fundamental concepts that you haven't learnt yet - like the fact that wildcards are expanded by the shell, not by individual programs. Learn the fundamentals and all will make sense. – cas Jun 9 '16 at 6:00
  • 1
    Two more fundamental concepts are escaping and quoting. If a character like * has a special meaning, you can "escape" or disable that special meaning with a backslash, e.g. runit \*. Or with quotes, e.g. runit '*' – cas Jun 9 '16 at 6:02

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.