Problem
AWK's printf requires the format string to be a string literal. When a variable or expression is used as the format argument, bashkit errors with "printf requires format string".
Reproduction
echo "my-project" | awk '{for(i=1;i<=NF;i++) printf substr($i,1,1)}'
Real awk: prints m (first char of "my-project")
Bashkit: awk: printf requires format string
Expected behavior
Per POSIX awk spec, printf accepts any string expression as the format argument:
printf expr # expr is used as format string
printf "%s", expr # explicit format
Both should work. The format string doesn't need to be a literal.
Workaround
# Instead of:
printf substr($i,1,1)
# Use:
printf "%s", substr($i,1,1)
Impact
Medium. The printf expr (without %s) pattern is common in awk one-liners. Used in wedow/ticket's generate_id() function.
Problem
AWK's
printfrequires the format string to be a string literal. When a variable or expression is used as the format argument, bashkit errors with "printf requires format string".Reproduction
Real awk: prints
m(first char of "my-project")Bashkit:
awk: printf requires format stringExpected behavior
Per POSIX awk spec,
printfaccepts any string expression as the format argument:Both should work. The format string doesn't need to be a literal.
Workaround
Impact
Medium. The
printf expr(without%s) pattern is common in awk one-liners. Used in wedow/ticket'sgenerate_id()function.