comp.lang.ada
 help / color / mirror / Atom feed
From: Markus E Leypold <development-2006-8ecbb5cc8aREMOVETHIS@ANDTHATm-e-leypold.de>
Subject: Re: Ada.Command_Line and wildcards
Date: Sat, 24 Feb 2007 17:45:14 +0100
Date: 2007-02-24T17:45:14+01:00	[thread overview]
Message-ID: <2wy7mn8pyd.fsf@hod.lan.m-e-leypold.de> (raw)
In-Reply-To: 1172328891.5496.62.camel@localhost.localdomain



Dear Georg, Dear all,

Georg Bauhaus <bauhaus@futureapps.de> writes:

> On Sat, 2007-02-24 at 12:46 +0100, Markus E Leypold wrote:
>> Martin Krischik <krischik@users.sourceforge.net> writes:
>> 
>> > here. And they got it wrong. Bot Dos and VMS will warn you on:
>>             ^^^^^^^^^^^^^^^^^^^
>> 
>> [...] On which criteria did
>> "they get it wrong"? Where are the specs against which the predicate
>> "right" can be tested?
>
> One criterion is the number of wildcard expansion surprises.
> Not having to mark patterns as patterns (untyped, no syntax)
> creates an immensely flexible and powerful ... mess.
>
> $ echo *.ads   # argument text is a pattern
> *.ads          #   output text is a pattern
>
> $ echo *.adb   # argument text is a pattern
> main.adb       #   output text is a file name
>
> $ ls *.ads
> ls: *.ads: No such file or directory
>
> $ ls *.adb
> main.adb
>
> (On the surface, ls(1) and echo(1) aren't consistently
> interpreting *.ads, one is reporting an error, the other
> is reproducing input. "But that's as defined, you ...
> If you can't be bothered to RTFM!")

Exactly ... that is as defined. I take it you're not overly familiar
with the Unix shell? Since this has nothing to do with " ls(1) and
echo(1) aren't consistently interpreting" but with exactly on quirk
the expansion (in the shell!) has:

 1. Expansion does always take place if the word is not quoted.
 
 2. If there is no file corresponding to the pattern, the result of the expansion
    is not '', but rather the pattern itself.

Thus we have

 echo *.ads --> echo '*.ads'    --> output: *.ads
 echo *.adb --> echo 'main.adb' --> output: main.adb

 ls *.ads   --> ls '*.ads'      --> try to stat() '*.ads', doesn't exist
 ls *.adb   --> ls 'main.adb'   --> try to stat() 'main.adb', output result

So ls and echo just act differently because they simply try to do
different things with the data they get passed: echo doesn't tell you
an error, because (as specified) it just has to echo it's arguments.

If you would have quoted, you'd have got the following results (note: no expansion takes place in all cases):

 echo '*.ads' --> output: *.ads
 echo '*.adb' --> output: *.adb

 ls '*.ads' --> try to stat() '*.ads', doesn't exist
 ls '*.adb' --> try to stat() '*.adb', doesn't exist

You see: Everything uniform, no heterogeneous behaviour at all.

I'm thus happy to note that your analysis seems to be based on a
certain lack of understanding how Unix or the Unix shells work. I'd
also like to insinuate that for a number of other contributions to
this thread. That can happen and certainly is no sin, but I humbly
suggest it might be advantageous to understand a thing before
asserting "it's all done wrong". At least it helps to get applicable
arguments instead of a bunch of misconceptions.

There is one point in what I elaborated where the Bourne shell might be
open to criticism: Point (2): If there is no file corresponding to the
pattern, the result of the expansion is not '', but rather the pattern
itself.

This has been a deliberate design choice to allow omitting the quotes
in many cases for convenience -- at the price of making it difficult
in some cases to assert wether the argument passed is a non-matching
pattern or the result of a successful expansion (this is hardly ever a
problem, not in interactive mode and good shell programmers know how
to handle that case).

But again this is no "as Unix handles arguments to programs" issue,
but rather choice taken in the design of specific shell language which
should provide enough power to start, stop, connect programs and at
the same time be easy to use interactively (i.e. without too much
typing).


> Since Unix shells use mostly text to represent almost all 
> information, the user is advised to remember text substitution
> pitfalls like the one above. Shell programming, for all its
> power, is like using Unchecked_Conversion by default, so to
> speak. In case of errors then, keeping track can be quite tricky,
> even more so when there is indirection, for example through
> popular backtick evaluation, as in
>
> $ foo=`echo .[a-z]*` ; some_cmd $foo ...

Well -- backtick is "out" anyway for the more complicated
cases. Especially when writing scripts I suggest to use $(...) --
which gets the nesting right.

>
> (run in a directory where there aren't any hidden files.)
>
> Caveat scriptor, the computer isn't programmed to help us
> here with type checking, OOD, etc..

Just use the scheme shell if you don't like Bourne shell. :-) 

But it is something you have to get used to, to properly quote ANY
arguments.


> That said, I'm looking forward to running Plan 9 again, on a
> virtual machine :)

Last time I checked (rather a bit ago that was) it couldn't run on
vmware or bochs: Has that changed?


Regards -- Markus





  reply	other threads:[~2007-02-24 16:45 UTC|newest]

Thread overview: 158+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21 20:43 Ada.Command_Line and wildcards Gautier
2007-02-21 20:59 ` (see below)
2007-02-22  1:13   ` Marc A. Criley
2007-02-22  2:08   ` Adam Beneschan
2007-02-22  5:59     ` (see below)
2007-02-22  8:16   ` gautier_niouzes
2007-02-22 10:25     ` Simon Wright
2007-02-22 11:02     ` Alex R. Mosteo
2007-02-24  6:34       ` Martin Krischik
2007-02-24 11:46         ` Markus E Leypold
2007-02-24 14:54           ` Georg Bauhaus
2007-02-24 16:45             ` Markus E Leypold [this message]
2007-02-24 20:08               ` Jacob Sparre Andersen
2007-02-24 20:45                 ` Georg Bauhaus
2007-02-25  0:39                   ` Björn Persson
2007-02-25 16:29                   ` Martin Krischik
2007-02-24 20:26               ` Georg Bauhaus
2007-02-25  7:46               ` Hyman Rosen
2007-02-25 13:19                 ` Georg Bauhaus
2007-03-05  1:07             ` Brian May
2007-03-05  1:39               ` Markus E Leypold
2007-03-06  3:48                 ` Brian May
2007-03-05 12:16               ` Georg Bauhaus
2007-03-05 13:20                 ` Markus E Leypold
2007-03-06 12:56                   ` Georg Bauhaus
2007-03-06 15:07                     ` Markus E Leypold
2007-03-07 22:06                       ` Georg Bauhaus
2007-03-08  5:07                         ` Simon Wright
2007-03-08  9:19                           ` Markus E Leypold
2007-03-08  9:28                           ` Georg Bauhaus
2007-03-08  9:16                         ` Markus E Leypold
2007-03-09 13:33                           ` Georg Bauhaus
2007-03-09 17:11                             ` Markus E Leypold
2007-03-09 18:22                               ` Dmitry A. Kazakov
2007-03-09 19:02                                 ` Markus E Leypold
2007-03-09 20:04                                   ` Dmitry A. Kazakov
2007-03-10 10:40                                     ` Markus E Leypold
2007-03-11  0:15                                 ` Hyman Rosen
2007-03-11  7:59                                   ` Dmitry A. Kazakov
2007-03-11 14:55                                     ` Markus E Leypold
2007-03-12 13:32                                     ` Hyman Rosen
2007-03-12 14:14                                       ` Dmitry A. Kazakov
2007-03-12 15:08                                         ` Markus E Leypold
2007-03-16  8:06                                           ` Brian May
2007-03-16 12:53                                             ` Markus E Leypold
2007-03-10  2:12                               ` Randy Brukardt
2007-03-10 10:52                                 ` Markus E Leypold
2007-03-10 15:48                               ` Georg Bauhaus
2007-03-10 18:11                               ` Jacob Sparre Andersen
2007-03-10 18:42                                 ` Markus E Leypold
2007-03-12 14:25                                   ` Jacob Sparre Andersen
2007-03-12 15:17                                     ` Markus E Leypold
2007-03-09 13:41                       ` Robert Deininger
2007-03-09 17:15                         ` Markus E Leypold
2007-03-09 18:58                           ` Larry Kilgallen
2007-03-10 10:27                             ` Markus E Leypold
2007-03-06 15:08                     ` Jacob Sparre Andersen
2007-03-07 19:21                     ` Hyman Rosen
2007-03-07 20:27                       ` Markus E Leypold
2007-03-07 21:12                       ` Georg Bauhaus
2007-03-06  3:07                 ` Brian May
2007-02-24 18:28           ` Martin Krischik
2007-02-24 13:04         ` Larry Kilgallen
2007-02-24 16:16           ` Markus E Leypold
2007-02-25 14:18             ` Larry Kilgallen
2007-03-05  1:03         ` Brian May
2007-03-05 10:34           ` Martin Krischik
2007-03-05 20:46             ` Simon Wright
2007-02-22 11:19     ` Jean-Pierre Rosen
2007-02-22 13:49       ` Maciej Sobczak
2007-02-22 14:25         ` Jean-Pierre Rosen
2007-02-22 15:12           ` Larry Kilgallen
2007-02-22 15:15           ` Ludovic Brenta
2007-02-22 15:54             ` Dmitry A. Kazakov
2007-02-22 18:26               ` Markus E Leypold
2007-02-22 19:34                 ` Dmitry A. Kazakov
2007-02-22 20:38                   ` Simon Wright
2007-02-23  8:43                     ` Dmitry A. Kazakov
2007-02-25 16:35                 ` wildcards with unix shells Martin Krischik
2007-02-22 16:20             ` Ada.Command_Line and wildcards Jean-Pierre Rosen
2007-02-22 18:34               ` Markus E Leypold
2007-02-22 19:30                 ` Niklas Holsti
2007-02-23  1:01                 ` Randy Brukardt
2007-02-23  4:44                   ` Jeffrey R. Carter
2007-02-23  5:06                   ` Anders Wirzenius
2007-02-24 16:37                     ` Simon Wright
2007-02-25 16:42                       ` Martin Krischik
2007-02-26 20:51                         ` Simon Wright
2007-02-27  7:11                           ` Martin Krischik
2007-02-27 21:32                             ` Björn Persson
2007-02-27 21:56                               ` Georg Bauhaus
2007-02-27 22:53                                 ` Markus E Leypold
2007-02-28 13:55                                   ` Georg Bauhaus
2007-02-28 14:25                                     ` Markus E Leypold
2007-02-26 11:59                       ` Anders Wirzenius
2007-02-26 14:46                         ` Larry Kilgallen
2007-02-23  8:43                   ` Jacob Sparre Andersen
2007-02-23 11:34                     ` Jean-Pierre Rosen
2007-02-24 13:40                       ` Jacob Sparre Andersen
2007-02-25 16:57                     ` Martin Krischik
2007-02-26 21:27                       ` Björn Persson
2007-02-27  7:18                         ` Martin Krischik
2007-02-23  8:49                 ` Jean-Pierre Rosen
2007-02-23  9:29                   ` Jacob Sparre Andersen
2007-02-22 17:07       ` Adam Beneschan
2007-02-22 18:40         ` Markus E Leypold
2007-02-23 10:47         ` Rob Norris
2007-02-23 13:28         ` brian.b.mcguinness
2007-02-23 13:56           ` Georg Bauhaus
2007-02-23 17:10           ` Adam Beneschan
2007-02-22 20:12       ` Gautier
2007-02-23  1:15       ` Robert A Duff
2007-02-23  9:25         ` Jacob Sparre Andersen
2007-02-24  1:18           ` typed pipes (was: Ada.Command_Line and wildcards) Björn Persson
2007-02-24  8:16             ` typed pipes Dmitry A. Kazakov
2007-02-24 13:37             ` Jacob Sparre Andersen
2007-02-24 16:33               ` Björn Persson
2007-02-24 20:17                 ` Jacob Sparre Andersen
2007-02-25  1:11                   ` Björn Persson
2007-02-25  7:03                     ` Jacob Sparre Andersen
2007-02-23 14:45         ` Ada.Command_Line and wildcards Larry Kilgallen
2007-02-24 19:24           ` Robert A Duff
2007-02-25  6:29             ` Hyman Rosen
2007-02-25 12:21               ` Robert A Duff
2007-02-25 16:22                 ` Pascal Obry
2007-02-25 16:44                   ` Dmitry A. Kazakov
2007-02-26  5:03                     ` Hyman Rosen
2007-02-26  8:44                       ` Dmitry A. Kazakov
2007-02-26 17:11                         ` Hyman Rosen
2007-02-26 17:34                           ` Markus E Leypold
2007-02-27 16:13                             ` Georg Bauhaus
2007-02-27 16:19                               ` Markus E Leypold
2007-02-27 16:39                                 ` Georg Bauhaus
2007-02-27 17:56                                   ` Markus E Leypold
2007-02-27 20:29                               ` Randy Brukardt
2007-02-26 20:30                           ` Dmitry A. Kazakov
2007-02-27  0:34                       ` Randy Brukardt
2007-02-27 14:52                         ` Hyman Rosen
2007-02-27 20:43                           ` Randy Brukardt
2007-02-27 20:56                           ` Dmitry A. Kazakov
2007-02-25 17:50                 ` Jeffrey R. Carter
2007-02-23 16:58         ` Adam Beneschan
2007-02-23 19:12           ` Hyman Rosen
2007-02-23 19:26             ` Adam Beneschan
2007-02-25 17:05               ` Martin Krischik
2007-02-24  1:19           ` Björn Persson
2007-02-24  3:46             ` Adam Beneschan
2007-02-24 11:42               ` Markus E Leypold
2007-02-25 17:02             ` Martin Krischik
2007-02-23 19:04         ` Hyman Rosen
2007-02-23 19:30           ` Adam Beneschan
2007-02-23 19:46             ` Dmitry A. Kazakov
2007-02-23 20:07             ` Markus E Leypold
2007-02-24  1:18             ` Björn Persson
2007-02-24 19:22           ` Robert A Duff
2007-02-24 20:26             ` Dmitry A. Kazakov
2007-02-25  7:32             ` Hyman Rosen
2007-02-21 21:43 ` Dr. Adrian Wrigley
replies disabled

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