Danek Duvall wrote:
On Thu, May 17, 2007 at 03:08:22PM +0700, Doug Scott wrote:

The patch for df.c below checks to see if stdout is a tty (i.e. interactive), and will add the -h option if no other options conflict. If stdout is not a tty (i.e. a script), the df command
is unchanged. Is there anything wrong with this idea??

isatty() has nothing to do with whether a command was run interactively.
It simply says whether a file descriptor is attached to a terminal.  So
with your change typing "df > out" or "df | less" wouldn't have the -h flag
added.  But running a script from the commandline with plain "df" in it
would still have stdout attached to the terminal, and would have the -h
flag added.

Maybe there's something you can do if you're running from a modern shell
that looks at process groups or sessions, but I'm not sure.

Danek
Ok, slightly bad wording by me :) I probably should have specified that the output is piped into another command to be further processed rather than be displayed. isatty(fileno(stdout)) can be used to give the desired result people have been asking for. i.e. Either for it to be read on the screen or processed by another command. I will remove the words interactive and scripts next time :)

Doug
_______________________________________________
opensolaris-discuss mailing list
opensolaris-discuss@opensolaris.org

Reply via email to