using 'printf' in a script in terminal window

Jerry gesbbb at yahoo.com
Sat Nov 21 21:47:30 CET 2009


On Sat, 21 Nov 2009 12:26:44 -0600
Mike McNally <emmecinque at gmail.com> replied:

> On Sat, Nov 21, 2009 at 12:13 PM, Jerry <gesbbb at yahoo.com> wrote:
> > On Sat, 21 Nov 2009 11:26:09 -0600
> > Mike McNally <emmecinque at gmail.com> replied:
> >
> >
> >> On Sat, Nov 21, 2009 at 11:14 AM, Jerry <gesbbb at yahoo.com> wrote:
> >> > On Sat, 21 Nov 2009 13:32:48 +0100
> >> > Mike Massonnet <mmassonnet at gmail.com> replied:
> >> >
> >> >> I tested it on Terminal, Konsole, and finally xterm, none of
> >> >> those clear the screen. And if xterm isn't doing pretty much
> >> >> nobody does it.
> >> >>
> >> >> Why don't you use `clear'?
> >> >
> >> > This would appear to be a "by design" feature; although I cannot
> >> > fathom why. Using 'clear' is fine as long as the script is not
> >> > used via CRON. 'Clear' produces strange output with scripts run
> >> > via CRON. I know that there are ways to program around that;
> >> > however, it does complicate things. I prefer the "KISS" approach.
> >> >
> >> > Although it probably would not make any appreciable difference, I
> >> > might appeal to the developers to change this behavior.
> >> >
> >> There's no truly standard character sequence that clears a terminal
> >> display, and there never has been. The '\f' code is a "form feed",
> >> which is a printer control to feed out paper up to the next page
> >> perforation.
> >>
> >> Most "terminal" programs (xterm et al) emulate old DEC VT-100
> >> terminals, which did not clear the screen in response to a form
> >> feed character, as far as I know.
> >
> > I am not familiar with how it worked historically. I do know that
> > there is a very real difference between how the printf "\f" command
> > works at a console and how it works within Terminal, xterm, etc. If
> > this was Microsoft, I might expect the left hand to be ignorant of
> > what the right hand is doing. Here, I would expect better.
> >
> > The bottom line is that this greatly inhibits my ability to fully
> > test scripts that I develop.

> Well that's why there's such a thing as the "clear" program: it
> figures out what sort of terminal you're printing to and what sort of
> special character sequence will cause the screen to be cleared, and
> it sends that out.
> 
> When you're doing standard printing out to any sort of "tty" device in
> Linux, with any window manager or desktop, the basic facts are the
> same: the software behaves pretty much exactly the same way it would
> have behaved 25 years ago when it would have been sending character
> through an RS-232 device to a *real* VT-100 (or ADM-3A or PE550 or
> any of the other zillion types of terminals, each with its own
> proprietary set of control codes).
> 
> If the console tty emulator interprets the form-feed character to mean
> that the screen should be cleared, that's great. The problem is that
> that's just one tty emulator out of many.
> 
> Also, for what it's worth, using "printf" to echo out a '\f'
> character doesn't cause my console screen to clear. It seems to be
> treated like a linefeed character. 

Out of morbid curiosity, what OS are you using? I have only tried on a
few other than FreeBSD; however, they all seem to work the same.
Obviously, that is at the console and not in an "X" session. So far, it
never works in "X".

As I stated previously, 'clear' causes a problem when used in
conjunction with CRON. While I can, and have, circumvented the problem,
I prefer not to have to.


-- 
Jerry
gesbbb at yahoo.com

|::::=======
|::::=======
|===========
|===========
|

It is difficult to soar with the eagles when you work with turkeys.




More information about the Xfce mailing list