From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cef74284c20fcef0,start X-Google-Attributes: gid103376,public From: "W. Wesley Groleau (Wes)" Subject: Overcoming shell bugs by writing Ada? Date: 1996/04/02 Message-ID: <9604021346.AA02498@most>#1/1 X-Deja-AN: 145452821 sender: Ada programming language comments: Gated by NETNEWS@AUVM.AMERICAN.EDU mailer: Elm [revision: 70.85] newsgroups: comp.lang.ada Date: 1996-04-02T00:00:00+00:00 List-Id: Robert I. Eachus 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 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, ); else -- must be absolute path Our_Private_File_Stuff.Open ( Filename, ); 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: /$TEST_FILES/test_one.tdl /./test_one.tdl /~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 ( ) 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 ---------------------------------------------------------------------------