comp.lang.ada
 help / color / mirror / Atom feed
* Overcoming shell bugs by writing Ada?
@ 1996-04-02  0:00 W. Wesley Groleau (Wes)
  1996-04-03  0:00 ` Fergus Henderson
  0 siblings, 1 reply; 2+ messages in thread
From: W. Wesley Groleau (Wes) @ 1996-04-02  0:00 UTC (permalink / raw)


Robert I. Eachus <eachus@SPECTRE.MITRE.ORG> wrote

I am dealing with a large mass (1000s) of source files.  I need to run
some tools over the code.  The choice was between Ada and a shell
script...I chose Ada:

generic
  with procedure To_Do(File: in String);
procedure Iterate_Files(Pattern: in String := "*";
                        Directory: in String := "");
-- This generic iterates over all files in a directory matching Pattern and
-- calls To_Do once for each ....


Mike Young <mikey@MCS.COM> answered:

I don't know about that, Robert. The equivalent shell script would be:


Back to Robert:

No, that shell script, like the vast majority of shell scripts around,
is buggy.  Writing correct, portable shell scripts is actually pretty tricky.


My turn:

On the other hand, that compiler, like the vast majority of compilers
around, is also buggy.  THIS MIGHT BE FIXED NOW, but a bug that bit my
last Verdix project (and also applied to SunAda) was that when you asked
them to open a file with Filename : String, they applied the following
logic (typical Unix hacking* follows):

if Filename(1) /= '/' then

   -- must be relative path
   Our_Private_File_Stuff.Open
   ( OS_Stuff.Get_CWD & "/" & Filename,    <other params> );

else

   -- must be absolute path
   Our_Private_File_Stuff.Open ( Filename, <other params> );

end if;

Result: even though all OUR tests passed, our users got lots of
NAME_ERROR exceptions with nothing to tell them why.

The debugger revealed to us that filenames like this didn't exist:

<output-of-OS_Stuff.Get_CWD>/$TEST_FILES/test_one.tdl
<output-of-OS_Stuff.Get_CWD>/./test_one.tdl
<output-of-OS_Stuff.Get_CWD>/~dsmith/test_one.tdl

Workaround:
Use command line arguments instead of prompting for filename, and
let the shell "correct" the filename strings.

Moral: What goes around, comes around.

I'm an Ada fan, too, but it's virtues don't quite justify editing and
compiling an instantiation to substitute for something as simple as

(this is csh)

foreach fn ( <file-pattern> )
  adaprog < $fn > $fn.result
end

* hacking in the sense of code-and-ship (rather than
  think-then-code-then-test)
--
---------------------------------------------------------------------------
W. Wesley Groleau (Wes)                                Office: 219-429-4923
I've got a compiler                                       FAX: 219-429-5194
and I'm not afraid to use it!                            Home: 219-471-7206
Magnavox - Mail Stop 10-40          QuickMail (Mac): wwgrol@most.fw.hac.com
Fort Wayne,  IN   46808              elm (Unix): wwgrol@pseserv3.fw.hac.com
---------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Overcoming shell bugs by writing Ada?
  1996-04-02  0:00 Overcoming shell bugs by writing Ada? W. Wesley Groleau (Wes)
@ 1996-04-03  0:00 ` Fergus Henderson
  0 siblings, 0 replies; 2+ messages in thread
From: Fergus Henderson @ 1996-04-03  0:00 UTC (permalink / raw)


"W. Wesley Groleau (Wes)" <wwgrol@PSESERV3.FW.HAC.COM> writes:

>Back to Robert:
>
>No, that shell script, like the vast majority of shell scripts around,
>is buggy.  Writing correct, portable shell scripts is actually pretty tricky.

To set the record straight, I was the one who wrote those words, not Robert.

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-04-03  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-02  0:00 Overcoming shell bugs by writing Ada? W. Wesley Groleau (Wes)
1996-04-03  0:00 ` Fergus Henderson

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