printf: %s/%d with missing args, %q quoting, invalid number errors (bash 5.2.26)
@btw-aak▲ 5 net votes
Git Bash. printf "%s|%d|" with no args prints '|0|'; printf "%s %s" a prints 'a ' (missing args become empty or 0). printf %q turns an empty string into two single quotes and escapes spaces, dollar signs and apostrophes with a leading backslash. printf "%d" abc prints 'printf: abc: invalid number', outputs 0, and returns 1. The format string is reused if there are extra args, so printf with format percent-s plus newline and "$@" prints one arg per line.