Re: [ILUG] A little grep mystery

From: Brian Foster (blf at domain utvinternet.ie)
Date: Tue 04 Jun 2002 - 14:13:49 IST


  | Date: Tue, 4 Jun 2002 09:05:28 +0100
  | From: Niall O Broin <niall at domain linux.ie>
  |
  | [ ... ] ps 'intelligently' cutting its output at column 80 if STDOUT
  | is not a tty. ps -efw saves the day but is there any way of stopping
  | ps from doing this permanent basis via an environment variable or a
  | configuration option? [ ... ]

 _permanently_??!? ah, well, Ok, each to their own ....
 create either of the following script (for most modern
 Bourne-ish shells), and install it as `ps', only after
 renaming the real `ps' as `ps.real':

     #!/bin/bash #/bin/bash
     export COLUMNS=1000 exec ps.real -w "$ at domain "
     exec ps.real "$ at domain "

 aliases and functions are not permanent, in the sense
 they do not, and can not, affect all users at all times.

<rant>
 should (GNU?) ps(1) do this? IMHO, no (with a possible
 exception):

  + line-chopping (_if_ that's what you want) is the job of
    either your terminak (hardware or, e.g., xterm(1)-ish
    program), or your PAGER (e.g., less(1)-ish program) ....

  + pipes and files are, by definition, a streams of bytes;
    lines/records/whatevers per se don't exist ....

  + the program reading the data from a pipe either needs
    to deal with arbitrary long lines (and it can chop if
    it so wants), or is the job of a helper tool (e.g.,
    a cut(1)-ish filter) deliberately stuck into the pipe
    for that purpose ....

  +(possible exception) if backwards compatibility is
    an issue, that's what the (e.g.) POSIXLY_CORRECT-ish
    environment variables are for; i.e., set as appropriate
    to achieve your desired effect ....

 if you have something you do "all the time" (read: "more
 than once"), package it up as a script --- rather than
 adding totally unnecessary complications which are then
 (esp. w.r.t. GNU) _not_ documented"! .... arrggghhhh!!!!
</rant>

cheers!
        -blf-

--
 Innovative, very experienced, Unix and      | Brian Foster    Dublin, Ireland
 Chorus (embedded RTOS) kernel internals     | e-mail: blf at domain utvinternet.ie
 expert looking for a new position ...       | mobile: (+353 or 0)86 854 9268
  For a resume, contact me, or see my website  http://www.blf.utvinternet.ie
    Stop E$$o (ExxonMobile):  «Whatever you do, don't buy Esso --- they
     don't give a damn about global warming.»    http://www.stopesso.com
     Supported by Greenpeace, Friends of the Earth, and numerous others...


This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:17:04 GMT