It is an extremely in-efficient way to use
printf() without using format specifiers. You generally define them to let know what type of output is being formatted. It should have been written as
printf '%s\n' "-----------"
Such that the
printf matches the
----------- as a string type with the format specifier that takes a string keyword (
\n after the specifier means, add the new line after the string is printed.
With the attempt what you have, when the quote removal happens
printf interprets the dashes as one of its command line flags, which it does not understand.
Another hacky way of doing it would be to let
printf know that its command line arguments are complete and interpret the content following it as its arguments. Most of the shell built-ins and/or external commands support this by suffixing a
-- after the command keyword, i.e. as
printf -- "-----------\n"