[pacman-dev] [PATCH] makepkg: use tput for terminal-safe colored and bold text
Allan McRae
allan at archlinux.org
Thu Oct 22 21:50:50 EDT 2009
Dan McGee wrote:
> On Thu, Oct 22, 2009 at 7:41 PM, Allan McRae <allan at archlinux.org> wrote:
>
>> Cedric Staniewski wrote:
>>
>>> Suggested-by: Dan McGee <dan at archlinux.org>
>>> Signed-off-by: Cedric Staniewski <cedric at gmx.ca>
>>> ---
>>>
>>> I do not know if this patch is usefull at all, because I do not notice any
>>> change. Just grabbed this from Dan's TODO list and wanted to play a bit
>>> with tput.
>>>
>>>
>> It looks fine to me...
>> I just have no idea on the advantage we are achieving with this change apart
>> from the apparent terminal safeness. Was the old version not safe?
>>
>> Dan: comments?
>>
>
> First comment- that TODO list is still huge, wow. :)
>
> Anyway, this seems pretty reasonable to me, but not sure it is worth
> it. At the least, we should capture these sequences once on script
> startup, and then use the global variable in each function. And does
> $(tput offbold) make more sense for the reset?
>
There does not appear to be such a thing as "tput offbold".
Anyway, I like the idea of setting these all at the start.
if [ $COLORMSG -eq 1 ]; then
BOLD_ON=$(tput bold)
BOLD_OFF=${tput srg0)
GREEN_ON...
...
fi
then the messages can just be
plain() {
local mesg=$1; shift
printf "${BOLD_ON} ${mesg}${BOLD_OFF}\n" "$@" >&2
fi
}
with none of the tests needed.
Allan
More information about the pacman-dev
mailing list