Since bash
evaluates quotation marks first, the final line evaluated is
printf --moish
which makes the error more evident. This is a common mistake in bash, where your first non-flag argument begins with a dash (-
), and it does not matter it is double. This also happens with grep
often as far as I have noticed. This makes the tool think you sent it a flag rather than the argument.
Most if not all tools (since this is a POSIX thing) allow for a --
flag for this case exactly - explicitly telling the tool that everything thing after is a regular argument, and not a flag:
printf -- --moish
Note the quotes are not even mandatory. They would be though if you wanted
printf -- "--moish\n"
to prevent premature evaluation of "\n".