From: Baho Utot on
unruh wrote:

> On 2010-06-08, Chris Davies <chris-usenet(a)roaima.co.uk> wrote:
>> Baho Utot <baho-utot(a)invalid.com> wrote:
>>> I have a bash script that outputs information like the following
>>> printf "Building --> ${i}: "
>>
>>> I would like to position to the start of that line and then erase it so
>>> I can update it with the current progress so I get "a stack" them like
>>> this
>>
>>> I don't know how to position the cusor to BOL so I can over write that
>>> line.
>
> The below is certainly one possibility. The other is to make sure that
> you use printf without and eol and then use backspaces to eliminate the
> previous stuff. Otherwise you will have the problem that the some lines
> being longer than the succeeding one, will have stuff from the previous
> line sticking out of the end the later one-- making for a messy screen.
>
> So print the stuff to a string, determine the length of the string, and
> then print out that number of backspaces.

[putolin]

I solved the problem like this:

printf "\r\e[KBuilding: ${_pkg} "

Thanks to every one who responded



From: Joe Beanfish on
On 06/08/10 19:03, Baho Utot wrote:
> unruh wrote:
>
>> On 2010-06-08, Chris Davies<chris-usenet(a)roaima.co.uk> wrote:
>>> Baho Utot<baho-utot(a)invalid.com> wrote:
>>>> I have a bash script that outputs information like the following
>>>> printf "Building --> ${i}: "
>>>
>>>> I would like to position to the start of that line and then erase it so
>>>> I can update it with the current progress so I get "a stack" them like
>>>> this
>>>
>>>> I don't know how to position the cusor to BOL so I can over write that
>>>> line.
>>
>> The below is certainly one possibility. The other is to make sure that
>> you use printf without and eol and then use backspaces to eliminate the
>> previous stuff. Otherwise you will have the problem that the some lines
>> being longer than the succeeding one, will have stuff from the previous
>> line sticking out of the end the later one-- making for a messy screen.
>>
>> So print the stuff to a string, determine the length of the string, and
>> then print out that number of backspaces.
>
> [putolin]
>
> I solved the problem like this:
>
> printf "\r\e[KBuilding: ${_pkg} "

That's accomplishing the same as the tput el mentioned by someone else
except that you're hard coding it for you terminal and may not work with
a different terminal type.

BTW, if you put the \e[K at the end instead of beginning the visual
effect will be more pleasing as it will eliminate the flashing as it
erases the redraws.

printf "\rBuilding: ${_pkg}\e[K"
From: Chris Davies on
On 06/08/10 19:03, Baho Utot wrote:
> I solved the problem like this:
> printf "\r\e[KBuilding: ${_pkg} "

Joe Beanfish <joe(a)nospam.duh> wrote:
> That's accomplishing the same as the tput el mentioned by someone else
> except that you're hard coding it for you terminal and may not work with
> a different terminal type.

Exactly. That's why it's so nice to use tools like tput.


Joe Beanfish <joe(a)nospam.duh> continued:
> BTW, if you put the \e[K at the end instead of beginning the visual
> effect will be more pleasing as it will eliminate the flashing as it
> erases the redraws.

> printf "\rBuilding: ${_pkg}\e[K"

For the record, a better way of writing this construct would be like this:
printf "\rBuilding: ${_pkg}"; tput el

Chris