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.