[unix-pc.general] Documented but un-obvious UNIX tricks

ford@cbmvax.UUCP (Michael "Ford" Ditto) (11/10/89)

In article <23698@cup.portal.com> thad@cup.portal.com (Thad P Floryan) writes:
>I've been informed the "ln" trick with respect to "ls" doesn't work with:
>
>	AT&T 386 running SysVR3.2, or
>	AT&T 3B2 600 running SysVR3.1.1

The "trick" of ls looking at its invocation name was present and
documented in 7th edition Unix, and is still in BSD.  I don't know exactly
when it was dropped, but it was not in SVR2.  It's one of the few cases
where I'm glad the Unix PC ended up with a pre-SVR2 version of a command.
The Unix PC ls source code contains various comments and code labelled
"UCB", and a comment: "Modified by Bill Joy and Mark Horton Sommer 1980".

>Sheesh.  Seems strange for features to be REMOVED from subsequent versions of
>AT&T System V; the UNIXPC's version is System V Release 2."something".

It is rather silly.  BTW, nobody ever officially said the Unix PC is
Release 2."something" -- it seems to be 80% SVR2, 10% SVR3, and 10% random
weirdness (pre-SVR2, BSD, and whatever).

>Can anyone with access to the just-released SVR4 verify the absence/presence
>of the shorthands for ls(1) and od(1) in that release?

SVR4 (at least the beta releases to date) doesn't have the ls link trick.

But speaking of SVR4 and Unix PC geneology -- SVR4 comes with TAM (the
Unix PC's curses-like windowing terminal support library) and even includes
some familiar include files:  Here, for example, are some exceprts from
/usr/add-on/include/sys/window.h, included by tam.h:

#define WIOCREAD	(WIOC|6)	/* read whole screen (32k)	*/
#define WIOCGETTEXT	(WIOC|7)	/* get window text info		*/
#define WIOCSETTEXT	(WIOC|8)	/* set window text info		*/
#define WIOCSYS		(WIOC|10)	/* set system window slot	*/
#define WIOCGETMOUSE	(WIOC|11)	/* get mouse info		*/
#define WIOCSETMOUSE	(WIOC|12)	/* set mouse info		*/
#define WIOCRASTOP	(WIOC|13)	/* user-level rastop		*/

/* slots in syswin for WIOCGET/SET SYS					*/
#define SYSWIN		3	/* number of sys wins	*/
#define SYSWMGR		0	/* window manager	*/
#define SYSPMGR		1	/* telephony manager	*/
#define SYSSMGR		2	/* status mgr		*/


In fact, <sys/window.h>, <sys/mouse.h>, even <sys/iohw.h> are present and
intact.  No, I don't think this means AT&T is thinking about porting SVR4
to the Unix PC, I think it just means they haven't finished sorting out
the machine-independent parts of TAM from the Unix PC specific parts.  It
is rather amusing to see:

#define VIDMEM		((usort *)0x420000)	/* mem addr	*/

in a header file on an Amiga running SVR4.
-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ditto@amix.commodore.com
- The Unix Programmer's Manual,		...!uunet!cbmvax!ditto
  2nd Edition, June, 1972.		ford@kenobi.commodore.com

mark@cblpf.ATT.COM (Mark Horton) (11/14/89)

In article <8504@cbmvax.UUCP> ford@cbmvax.UUCP (Michael "Ford" Ditto) writes:
>In article <23698@cup.portal.com> thad@cup.portal.com (Thad P Floryan) writes:
>>I've been informed the "ln" trick with respect to "ls" doesn't work with:
>>
>>	AT&T 386 running SysVR3.2, or
>>	AT&T 3B2 600 running SysVR3.1.1
>
>The "trick" of ls looking at its invocation name was present and
>documented in 7th edition Unix, and is still in BSD.  I don't know exactly
>when it was dropped, but it was not in SVR2.  It's one of the few cases
>where I'm glad the Unix PC ended up with a pre-SVR2 version of a command.
>The Unix PC ls source code contains various comments and code labelled
>"UCB", and a comment: "Modified by Bill Joy and Mark Horton Sommer 1980".

I can confirm most of this, except that it wasn't in V7.  There was always
a standard Berkeley enhancement where "ls" would print in columns if stdout
was a tty but (for upward compatibility with shell scripts) down the left
edge if stdout was a pipe, file, etc.  Once a person has used an ls with
this feature, they usually refuse to go back to the System V release 1
notion of "always down the left edge."  A typical UNIX system port with
"Berkeley enhancements" usually had vi, csh, more, and the Berkeley ls,
and maybe a few other odds and ends.

About the same time, some Bell Labs folks in IH were doing their own
enhancments.  They added their own version of -F, which put brackets
around directories: "[dir]", and stars after executables.  We heard
about this at Berkeley, and discovered they were using our version of
ls.  We didn't care for the brackets: 14 char file names plus 2 chars
of brackets doesn't line up nicely with 16 character columns, and we
wanted the columns at 16 so we could use hardware tabs.  The result
was a compromise, there was an ifdef in the code so that you could get
the IH or the UCB behavior.  The last character stuff was added at the
same time, although I can't remember whose idea it was, it was heavily
used by both Berkeley and IH.  (The "lf" command, in particular, is
still heavily used at IH.)

I think Bill was less enthusiastic about the last char hack, so 4BSD
wasn't distributed with the links, but 2BSD, which I handled at the
time, was.

System V has since added the -C option, which, when combined with an
alias, does the job (except that it always prints in columns, even
if you don't want it to.)  System V release 4 has most of the nice
Berkeley features with -C on-default-unless-tty and -1, although I
don't think the "last char" hack was requested, so it's not there.
The simple fact is, that for any version of ls that allows multiple
option arguments (as the System V version does) an alias does this
just as well as a link, so there's no good reason to add it to the system.

Incidently, the "multi-column if tty" business is not without controversy.
Rob Pike and others at Murray Hill don't like the fact that it doesn't
do the same thing if piped somewhere.  They have a point, but I think
most people feel that it's better not to break shell scripts but to have
a decent looking display on your screen (instead of zipping off the top).

The UNIX PC does not run straight System V.  It runs System V release 2
plus lots of neat stuff that Conversant thought would be nice.  The
Berkeley ls seems to be one thing they added.  I for one appreciated
their enhancements, it made the machine a lot friendlier, and I had
to bring less personal baggage onto the system to make it usable.

By the way, I don't see the "last char hack" documented in any of my
4BSD or RDS (IH) manuals, so I'm not sure where you're looking.

	Mark Horton

ford@cbmvax.UUCP (Michael "Ford" Ditto) (11/14/89)

In article <8504@cbmvax.UUCP> I wrote:
>The "trick" of ls looking at its invocation name was present and
>documented in 7th edition Unix, and is still in BSD.

In article <11381@cbnews.ATT.COM> mark@cblpf.ATT.COM (Mark Horton) writes:
>I can confirm most of this, except that it wasn't in V7.

Hmm.  I just remembered that the V7 system I used was actually "TNIX"
(V7 + a very few enhancements on a Tektronix LSI 11/23 system), so I'll
take Mark's word for it.
-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ditto@amix.commodore.com
- The Unix Programmer's Manual,		...!uunet!cbmvax!ditto
  2nd Edition, June, 1972.		ford@kenobi.commodore.com

jcm@mtunb.ATT.COM (was-John McMillan) (11/15/89)

In article <11381@cbnews.ATT.COM> mark@cblpf.ATT.COM (Mark Horton) writes:
:
 ! The UNIX PC does not run straight System V.  It runs System V release 2
 ! plus lots of neat stuff that Conversant thought would be nice.  The
                                ==========
 ! Berkeley ls seems to be one thing they added. ...

	Looks like one of my typos!  But to protect the innocent, it
	should be muttered that CONVERGENT TECHNOLOGIES was probably
	intended, above.

john mcmillan	-- att!mtunb!jcm -- Muttering for SELF, not THEM

mjs@schoen.UUCP (Mike Schoenborn) (11/16/89)

Ah, but when is "ll" not quite the same as "ls -l"?  Try to redirect the
output.  (Go ahead, I'll wait.)  Uh huh.  Is this ill behavior noted in the
docs (that didn't come with the filesale machines)?
-- 
Mike Schoenborn  osu-cis!n8emr!uncle!schoen!mjs  mjs@schoen.UUCP  cis:70010,147