I am looking to do some formatting of the output from my makefile using tput. An example: if you simply type
echo $(printf '%*s' "${COLUMNS:-$(tput cols)}" '' | tr ' ' –)
as a command in your shell it will output a nice line spanning the entire width of your terminal window.
I am wondering if there's any way to carry this over in a makefile? The following only produces a blank line:
lineTest:
@echo $$( printf '%*s' "${COLUMNS:-$(tput cols)}" '' | tr ' ' – )
Definitely a silly question, but please do chime in if you happen to know.
You have to escape ALL the $ you want to pass to make. You only escaped the first one. Also I don't know why you're invoking printf in a subshell then echoing the results...??
This works for me:
lineTest:
@printf '%*s\n' "$${COLUMNS:-$$(tput cols)}" '' | tr ' ' -
I should point out, this won't work reliably if you invoke make with parallel builds enabled, because in parallel mode not all of the jobs get access to the terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With