[net.unix-wizards] With respect to "pr"

zben@umd5.UUCP (06/19/85)

There was a description of the Amiga posted to one of the micro groups, but
it was posted in 40 column format.  Remembering something I got to work with
the Software Tools on the Univac, I read my manual, then tried the following
command to put the article ("source") into 80 column format:

% pr -m -2 - - <source
can't print 0 cols, using 1 instead.
can't print 0 cols, using 1 instead.
pr: Too many args

Analysis: -m -2 says merge to two columns, but making both arguments dash was
supposed to bind both inputs to stdin, so pr would actually read alternate
lines from the same file, i.e., the pipe from "source".  Actually, pr does not
seem to believe in the - for stdin convention, and is parsing the arguments
as "-0" for zero column, i.e., passing a null string to atoi() and getting
zero back...

Now, I realize that it's a trivial thing to do with "awk":

awk '
NR%2!=0 { s = substr($0,1,40) }
NR%2==0 { printf "%s %s\n",s,substr($0,1,40)  }
'

and that's eventually how I did it.  Talking this over with my local guru,
he started getting nasty, and said that even if I added the "-" for stdin
code to pr he wouldn't install it on the system.  Something about trying
to keep unix the same on all the machines, and he couldn't convince all the
other gurus to do it to their unixes too.  The same kind of arguments that
got us called high priests in the first place...

I would appreciate a few words (in MAIL please) from gurus of long standing,
like over 10 years in, on why my suggestion is so bogus.
-- 
Ben Cranston  ...{seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben  zben@umd2.ARPA

chris@umcp-cs.UUCP (Chris Torek) (06/19/85)

Perhaps a better solution is our (well Fred's but...) ``file descriptor''
driver (similar to /dev/stdin in Eighth Edition Unix).  Just have your
program read /dev/fd0; no special casing required.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland

faigin@sdcrdcf.UUCP (Daniel Faigin) (06/21/85)

In article <322@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes:
>Perhaps a better solution is our (well Fred's but...) ``file descriptor''
>driver (similar to /dev/stdin in Eighth Edition Unix).  Just have your
>program read /dev/fd0; no special casing required.

Couldn't this be done in other Unixes by using /dev/tty
explicitly?

Daniel
-- 
UUCP: {akgua allegra ihnp4 hplabs sdcsvax trwrb cbosgd}!sdcrdcf!faigin  
ARPA: sdcrdcf!faigin@UCLA-LOCUS.ARPA --or-- sdcrdcf!faigin@LOCUS.UCLA.EDU

W: SDC, 2500 Colorado MD 52-46; Santa Monica CA 90406; (213) 820-4111 x6493
H: 11743 Darlington Avenue #9; Los Angeles CA 90049; (213) 826-3357

Don't have good ideas if you aren't willing to be responsible for them.
                                 -- A. J. Perlis, SIGPLAN 17:9 Sept 1982

david@ukma.UUCP (David Herron, NPR Lover) (06/24/85)

In article <2091@sdcrdcf.UUCP> faigin@sdcrdcf.UUCP (Daniel Faigin) writes:
>In article <322@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes:
>>Perhaps a better solution is our (well Fred's but...) ``file descriptor''
>>driver (similar to /dev/stdin in Eighth Edition Unix).  Just have your
>>program read /dev/fd0; no special casing required.
>
>Couldn't this be done in other Unixes by using /dev/tty
>explicitly?
>

Sheesh!  I thought this was net.unix-wizards!


Daniel, I sentence thee to 500 readings of "UNIX for Beginners -- Second Edition"
It's written by Brian Kernighan, and you *ought* to be able to find
it stored in /usr/doc or /usr/docs.  Failing that, look in Volume 2B
of the Programmers manual (It's right in the front)

		:-)

How often is stdin *not* /dev/tty?
-- 
--- David Herron
--- ARPA-> ukma!david@ANL-MCS.ARPA or ukma!david<@ANL-MCS> 
---	   or david%ukma.uucp@anl-mcs.arpa
---        Or even anlams!ukma!david@ucbvax.arpa
--- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david
---        {ihnp4,decvax,ucbvax}!cbosgd!ukma!david

	"It's *Super*User* to the rescue!"

zben@umd5.UUCP (06/25/85)

In article <2091@sdcrdcf.UUCP> faigin@sdcrdcf.UUCP (Daniel Faigin) writes:
>In article <322@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes:
>>Perhaps a better solution is our (well Fred's but...) ``file descriptor''
>>driver (similar to /dev/stdin in Eighth Edition Unix).  Just have your
>>program read /dev/fd0; no special casing required.
>
>Couldn't this be done in other Unixes by using /dev/tty
>explicitly?

No, in the original example standard input was redirected from a file...

-- 
Ben Cranston  ...{seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben  zben@umd2.ARPA

ed@mtxinu.UUCP (Ed Gould) (06/27/85)

In article <2091@sdcrdcf.UUCP> faigin@sdcrdcf.UUCP (Daniel Faigin) writes:
>In article <322@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes:
>>Perhaps a better solution is our (well Fred's but...) ``file descriptor''
>>driver (similar to /dev/stdin in Eighth Edition Unix).  Just have your
>>program read /dev/fd0; no special casing required.

As I remember, /dev/stdin is a link to /dev/fd0 in the Eighth Edition.
Certainly, they should both exist.

>Couldn't this be done in other Unixes by using /dev/tty
>explicitly?

Only if stdin to the process in question is the terminal.  Often, it's
a pipe or some other such thing.

-- 
Ed Gould		    mt Xinu, 2910 Seventh St., Berkeley, CA  94710  USA
{ucbvax,decvax}!mtxinu!ed   +1 415 644 0146

"A man of quality is not threatened by a woman of equality."

tim@cithep.UucP (Tim Smith ) (07/04/85)

Summary of original article:  pr does not accept '-' in place of a file name
to mean use stdin.  The posters local guru said it is not reasonable to
change pr.  The poster wants to know if other gurus think the same way.

Summary of responses:  If he was on V8 he could use /dev/stdin.

Attempt to answer original question:  Your local guru should either let
you make the change to pr, or he should let you put /dev/stdin in
your kernel.  Try to talk him into the later.  He will probably refuse,
and after a bit of arguing, you can probably compromise on the former! :-)


-- 
Q: what did the programmer who turned down a job at Bell say?
A: I could have had a V8
					Tim Smith
				ihnp4!{wlbr!callan,cithep}!tim

whp@cbnap.UUCP (W. H. Pollock x4575 3S235) (07/09/85)

Modifying pr (on sys VR2 anyway) is not reasonable!  This program is so buggy,
convoluted, and bizzare that the only reasonable thing to do is to rewrite it
from scratch!  I tried to fix a bug once, the -w option doesn't work unless
you have more than two columns;  simply removing the test for number of columns
caused pr to stop printing the first line of random pages!  (this fix was
given to me by UNIX support people, and even they gave up on pr!)