comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Interpretation of extensions different from Unix/Linux?
Date: Thu, 20 Aug 2009 15:44:36 -0400
Date: 2009-08-20T15:44:36-04:00	[thread overview]
Message-ID: <wccljlei82j.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 8763cj53ir.fsf@jspa-nykredit.sparre-andersen.dk

Jacob Sparre Andersen <sparre@nbi.dk> writes:

> Robert A Duff wrote:
>> Of course, it's all ridiculous: hiding file names that start with
>> "." is a stupid idea.  Expanding wildcards on the command line and
>> then passing separate args as strings is a stupid idea.  This is one
>> of the (few) areas where Windows does it right, compared to Unix.
>> Sigh.
>
> Expanding wildcards on the command line centralises that feature, so
> the users don't have to worry about how the individual applications
> have decided to implement wildcard expansion.

Yes, that is an advantage of having the shell do it,
(although "centralized" is somewhat dubious.  It's centralized
in 'sh'.  And 'csh'.  And 'bash'.  And 'find'.  And dozens of others.)
However, there are so many disadvantages, that I think
this part of Unix is just plain broken:

Note that I said, "passing separate args as strings", and I think that's
the worst part of it.  Defining the semantics of a language in terms of
textual manipulations is a Bad Idea.  That's why C macros are evil.  And
why pretty much the entire 'sh' language is such a horror.  And all the
other Unix shells are just as bad.  This is why 'make' is such a mess.
In Ada, the semantics of "X, Y: array ...;" are defined in terms of
textual substition, which leads to various surprises.  At least this
design mistake doesn't permeate Ada.

Textual substition is a simple rule (just change "*.ada" to
"foo.ada bar.ada baz.ada", or whatever).  But it leads to
complicated and surprising consequences.

If I say, "cp *.ada backup", it means copy all the *.ada files
into the backup directory.  Suppose I accidentally hit <enter>
before typing "backup", so I say, "cp *.ada".  On a reasonable
system, I'd get an error -- one argument passed, but 'cp' is
expecting two.  On Unix, I usually get an error, but it's
something nonsensical, like "zoo.ada is not a directory".
And if it just so happens that there are exactly two files
matching *.ada, I get no error -- instead of backing up
my files, it destroys one of them!

Here's another stupidity:

% grep somethingorother *.ada
Arguments too long
% grep somethingorother `find some-directory -name '*.ada'`
Too many words from ``

The idea that all the file names have to be stored in memory during the
search is just plain broken.  What if I wanted to search all the files
on my huge disk?  (Side issue: Unix doesn't have a standard wildcard
that means "a certain directory, and all subdirectories underneath that
in the tree".  You have to use 'find' -- yuck.)  (Another side issue:
grep takes it arguments in backwards order, because of the way
wildcards work in Unix.)

Unix exacerbates this problem by using a fixed-size buffer for the
command line.  No matter how big it is, it is always both too big and
too small.

(Why is the "search" command called "grep"?  For that matter, why is the
"help" command called "man"?)

>...I would definitely not
> be happy with a system, where each and every program had a slightly
> different interpretation of a wildcard.

Agreed.

But it doesn't have to be that way.  On VMS, wildcards are treated in a
completely uniform manner.  The OS provides a service to iterate through
the files corresponding to a given wildcard, and all programs use it.
No problem.  Same is true on other OS'es I've used.

The problem you describe did exist on MS-DOS, and on Windows
(although I think it's not as bad as it used to be) -- which is
surprising, since DOS provided a similar service to VMS.
I admit that the Unix design prevents this problem.
But even if you insist on having the shell expand wildcards,
"cp *.ada backup" should pass exactly 2 arguments to 'cp' --
a list of file names, and a directory name.

> Given how anarchistic most "unix programmers" are, this is definitely
> a more user friendly solution.

Sigh.  No language/OS design can prevent incompetent programmers from
making a mess.  To me, it seems sufficient to have a (standard!) service
that says "Apply so-and-so procedure to each file (or file name) that
matches such-and-such wildcard."  I don't know why it worked well on
VMS, but not on MS-DOS.

Sorry for the mostly off-topic rant.  The Ada question is: to what
extent should Ada.Directories mimic all this foolishness?

- Bob



  parent reply	other threads:[~2009-08-20 19:44 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-01 17:53 Interpretation of extensions different from Unix/Linux? vlc
2009-08-02 17:13 ` Jacob Sparre Andersen
2009-08-04 11:31   ` vlc
2009-08-04 11:44     ` Jacob Sparre Andersen
2009-08-04 11:57       ` Georg Bauhaus
2009-08-04 12:29         ` vlc
2009-08-04 13:43         ` Dmitry A. Kazakov
2009-08-14  4:33           ` Randy Brukardt
2009-08-14  7:37             ` Dmitry A. Kazakov
2009-08-04 12:25       ` vlc
2009-08-04 19:18         ` Jeffrey R. Carter
2009-08-04 19:52           ` Dmitry A. Kazakov
2009-08-04 20:45             ` Jeffrey R. Carter
2009-08-04 21:22               ` Dmitry A. Kazakov
2009-08-04 22:04                 ` Jeffrey R. Carter
2009-08-05  8:33                   ` Dmitry A. Kazakov
2009-08-05 16:07                     ` Jeffrey R. Carter
2009-08-05 16:35                       ` Dmitry A. Kazakov
2009-08-05 17:49                         ` Jeffrey R. Carter
2009-08-05 18:16                           ` Dmitry A. Kazakov
2009-08-05 19:27                             ` Jeffrey R. Carter
2009-08-05 19:50                               ` Dmitry A. Kazakov
2009-08-05 20:46                                 ` Jeffrey R. Carter
2009-08-06  7:43                                   ` Dmitry A. Kazakov
2009-08-05 21:33                               ` Robert A Duff
2009-08-05 19:45                           ` vlc
2009-08-05 19:56                             ` Dmitry A. Kazakov
2009-08-14  4:56                     ` Randy Brukardt
2009-08-14  8:01                       ` Dmitry A. Kazakov
2009-08-14 23:02                         ` Adam Beneschan
2009-08-14 23:54                         ` Randy Brukardt
2009-08-15  8:10                           ` Dmitry A. Kazakov
2009-08-15 12:49                             ` Pascal Obry
2009-08-15 13:23                               ` Dmitry A. Kazakov
2009-08-15 15:11                                 ` Pascal Obry
2009-08-15 17:11                                   ` Dmitry A. Kazakov
2009-08-15 20:07                                     ` Pascal Obry
2009-08-16  7:26                                       ` Dmitry A. Kazakov
2009-08-17 22:28                             ` Randy Brukardt
2009-08-18  0:32                               ` Adam Beneschan
2009-08-18 20:48                                 ` Randy Brukardt
2009-08-19  4:08                                   ` stefan-lucks
2009-08-19 22:01                                     ` Randy Brukardt
2009-08-19  7:37                                   ` Jean-Pierre Rosen
2009-08-19 16:10                                   ` Adam Beneschan
2009-08-19 22:11                                     ` Randy Brukardt
2009-08-18  7:48                               ` Dmitry A. Kazakov
2009-08-18 20:37                                 ` Randy Brukardt
2009-08-19  8:04                                   ` Dmitry A. Kazakov
2009-08-19 10:32                                     ` Georg Bauhaus
2009-08-19 12:11                                       ` Dmitry A. Kazakov
2009-08-19 15:21                                         ` Georg Bauhaus
2009-08-19 22:40                                     ` Randy Brukardt
2009-08-20  8:00                                       ` Variable- and fixed-length-character strings (Was: Interpretation of extensions different from Unix/Linux?) Jacob Sparre Andersen
2009-08-20 19:40                                       ` Interpretation of extensions different from Unix/Linux? Dmitry A. Kazakov
2009-08-21  0:08                                         ` Randy Brukardt
2009-08-21  7:43                                           ` Dmitry A. Kazakov
2009-08-21 22:10                                             ` Randy Brukardt
2009-08-22  7:27                                               ` Dmitry A. Kazakov
2009-09-01  1:50                                                 ` Randy Brukardt
2009-09-01  7:28                                                   ` Dmitry A. Kazakov
2009-09-02  3:41                                                     ` Stephen Leake
2009-09-02  7:17                                                       ` Dmitry A. Kazakov
2009-09-02 19:49                                                         ` tmoran
2009-09-03  7:41                                                           ` Dmitry A. Kazakov
2009-09-03 17:27                                                             ` tmoran
2009-09-03 20:44                                                               ` Dmitry A. Kazakov
2009-09-03 22:22                                                                 ` Randy Brukardt
2009-09-04  7:40                                                                   ` Dmitry A. Kazakov
2009-09-05  1:58                                                                     ` Randy Brukardt
2009-09-05  2:08                                                                     ` Randy Brukardt
2009-09-05  8:59                                                                       ` Dmitry A. Kazakov
2009-08-21 10:11                                           ` Enumeration of network shared under Windows (was: Interpretation of extensions different from Unix/Linux?) Dmitry A. Kazakov
2009-08-15 16:01                           ` Interpretation of extensions different from Unix/Linux? Vadim Godunko
2009-08-16 13:13                           ` Stephen Leake
2009-08-14  4:46                 ` Randy Brukardt
2009-08-14  9:00                   ` Dmitry A. Kazakov
2009-08-04 21:19           ` vlc
2009-08-14  5:19     ` Randy Brukardt
2009-08-14  6:13       ` Wilcards in Linux (was: Interpretation of extensions different from Unix/Linux?) stefan-lucks
2009-08-14  6:24         ` stefan-lucks
2009-08-14 10:05         ` Wilcards in Linux Markus Schoepflin
2009-08-14 10:22           ` Ludovic Brenta
2009-08-14 18:20             ` Tero Koskinen
2009-08-19 20:39       ` Interpretation of extensions different from Unix/Linux? Keith Thompson
2009-08-19 22:09         ` Robert A Duff
2009-08-20  7:49           ` Jacob Sparre Andersen
2009-08-20 15:56             ` Adam Beneschan
2009-08-20 21:58               ` sjw
2009-08-20 19:44             ` Robert A Duff [this message]
2009-08-20 21:34               ` Adam Beneschan
2009-08-20 22:03                 ` (see below)
2009-08-21  0:55                 ` tmoran
2009-08-20 23:55               ` Randy Brukardt
2009-08-21 17:58               ` Keith Thompson
2009-08-21 18:34                 ` Dmitry A. Kazakov
2009-08-21 19:32                 ` Jeffrey R. Carter
2009-08-21 21:34                 ` Robert A Duff
2009-08-21 22:06                   ` Hyman Rosen
2009-08-24 19:51                   ` Keith Thompson
2009-08-28  0:27                     ` Robert A Duff
2009-08-28 13:15                       ` Anders Wirzenius
2009-08-28 15:02                         ` Robert A Duff
2009-08-21  8:45             ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox