I'm trying to use printf to format some pretty output in a bash script
e.g.:
-----------------------
| This is some output |
-----------------------
But I've stumbled over some behavior I don't understand.
$ printf "--"
gives me the error:
printf: usage: printf [-v var] format [arguments]
and
$ printf "-stuff"
results in
-bash: printf: -s: invalid option
So apparently printf thinks I'm trying to pass some arguments while I'm not.
Meanwhile, completely by accident, I've found this workaround:
$ printf -- "--- this works now ----\n"
gives me
--- this works now ----
Can anyone explain this behavior?
echothat would fail when doingecho ------------? Most only support-n(no trailing newline),-e(interpret backslash-escaped chars) and possible-E(do NOT interpret them) and do not error out when other option-like arguments are encountered, right? (EDIT: GNU's/bin/echoalso supports--helpand--version.)