[X-Unix] rsync & ssh [DRIFT]

David Ledger dledger at ivdcs.demon.co.uk
Fri Jul 9 04:44:27 PDT 2004


>From: Stroller <MacMonster at myrealbox.com>
>Subject: Re: [X-Unix] rsync & ssh
>Date: Thu, 8 Jul 2004 00:07:21 +0100
>
>On Jul 7, 2004, at 12:07 pm, David Ledger wrote:
>>>  From: Stroller <MacMonster at myrealbox.com>
>>>  Unix is *horribly* obscure & complex, and for no good reason other
>>>  than
>>>  compatibility with legacy systems.
>>  Not sure what you mean here.  I can't think of any legacy systems it's
>>  particularly compatible with.
>
>Well, what I mean is basically that Unix stays horribly obscure &
>complicated in in order to remain compatible with Unix.

So really you're complaining that Unix still exists, and hasn't been 
replaced with a new OS with similar internals and different CLI 
utilities.

>`ls -l foo` means "show full details of the file foo"
>`ls -l -R` means "show full details of all the files in the directory &
>all directories below it"
>
>`grep foo bar` means "look for foo in the file bar"
>`grep -R bar` means "look (recursively?) for bar on standard input"

Yes, but recursive is redundant for stdin.  The '-' indicates a flag, 
and would be just as valid in the first version provided 'bar' were a 
directory.  I don't see a problem here.  You have to think about how 
a utility writer is going to get the info it needs from you.  'ls' 
and 'grep' both work on multiple files/directories.  The only place 
on a command line you can put a variable length list without adding 
other markers is at the end.  Optional flags and flags with arguments 
come at the beginning.  The presence of the '-' means the utility 
code can distinguish between flags and main arguments.  From the 
'grep' manpage:
	grep [options] PATTERN [FILE...]
	grep [options] [-e PATTERN | -f FILE] [FILE...]
There is only one word allowed for 'PATTERN'.  As the code scans its 
args list left to right, once it's seen a 'PATTERN' word, the rest 
specify files to operate on (or stdin if none).  This is exactly the 
same as for 'ls' except that 'ls' only needs flags and filenames 
(directories being a type of file), nothing like 'PATTERN'.

>So to show full details of the file "-R" we use `ls -l -- -R`
>But to look for the expression "-R" in the file bar we use `grep -e -R
>bar`

Under the old versions of Unix (the ones you were complaining we have 
to be compatible with :-) ), '--' meant nothing, or possibly a flag 
called '-'.  The first time I met '--' was under Linux.  It's not 
normally used in mainstream Unix AFAIK, certainly not HP-UX.  Doing 
an 'ls -l' on a file called '-R' was only a problem if you were 
stupid enough to create a file called '-R'.  Users knew not to do 
that or live with the consequences.  If you had to, you'd do 'ls -l x 
-R' and ignore the line complaining that 'x' was not found.  'x' is 
one less keystroke than '--'.

>`tar` requires the -f flag to indicate that the following argument is
>the name of a file on which to operate, whereas the file to operate on
>is always the last argument to the `gzip` command.

You're seeing it backwards.  'tar' is just the same as the above. 
The files it operates on are those after the flags (or keys as real 
tar call them - a block of chars specifying what to do is _required_, 
and so no '-' is needed to introduce them).  If the key includes c, 
a, r, u ... those files listed at the end of the line are put 
together in an archive.  If the key includes x (or t), files with the 
names specified at the end of the line are extracted (or metadata 
listed) from an archive, the default being "all".  The '-f 
<filename>' is optional, the default being the first tape device. 
The items to operate on (archive) must be supplied.

This is confused on OSX because OSX 'tar' is actually 'gnutar', which 
is not Unix (GNU = Gnu's Not Unix), so the problem comes from not 
sticking with the old :-).

>Unix would be less
>horribly complicated, quicker to learn for beginners & handier for
>experienced users alike, if flags were standardised and some of these
>anomalies revised, however some overnight "standardisation" would break
>every shell-script on the planet.

There are only 26 * 2 letters to use as flags and at least ten times 
that many options to specify with them.  Some sites use both new and 
ten year old boxes with current and ten year old OS revisions 
together, running common scripts on both.  Y2K reduced this, but 
we'll have HP-UX 10.20 (unsupported for a year now) from the mid 90s 
still running in 2010 because of discontinued s/w products.


and

At 5:58 am -0700 8/7/2004, Stroller <MacMonster at myrealbox.com>:
>I would regard there to be something inherently legacy about a
>command-line for which many of the principal tools are still called
>according to the whims of the authors who conceived them twenty or
>thirty years ago.

The only computer thing I've seen that uses meaningful names was 
COBOL.  The naming of 'grep', 'awk', 'tar' may seem odd to newcomers, 
but what would you call them so that new users would know what they 
do from the name?


and

At 5:58 am -0700 8/7/2004, Brian Medley <bpm-list-osx-unix at 4321.tv>:
>It would not have to break every shell script.  For example, the
>behavior of some versions Solaris depends on your path.

The behavior of _all_ versions of Unix depends on your PATH.


David



-- 
David Ledger - Freelance Unix Sysadmin in the UK.
Chair of HPUX SysAdmin SIG of hpUG technical user group (www.hpug.org.uk)
dledger at ivdcs.co.uk (also dledger at ivdcs.demon.co.uk)
www.ivdcs.co.uk



More information about the X-Unix mailing list