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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,14aa27db81ce3b40 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!news-peer-lilac.gradwell.net!not-for-mail From: Rob Norris Newsgroups: comp.lang.ada Subject: Re: How to exit an Ada program with (unix shell) error code? Date: Tue, 05 May 2009 11:49:54 +0100 Message-ID: References: <49ba30c9-a1e6-4346-8618-d256f87ac301@s31g2000vbp.googlegroups.com> X-Newsreader: Forte Free Agent 3.3/32.846 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Original-NNTP-Posting-Host: glkas0286.greenlnk.net NNTP-Posting-Host: 20.133.0.1 X-Trace: 1241520598 news.gradwell.net 513 dnews/20.133.0.1:30887 X-Complaints-To: news-abuse@gradwell.net Xref: g2news2.google.com comp.lang.ada:5689 Date: 2009-05-05T11:49:54+01:00 List-Id: On Mon, 04 May 2009 16:09:01 GMT, anon@anon.org (anon) wrote: > >-- >-- Besides the Ada.Command_Line you can just use functions for >-- the instead of procedures for your nain program. This design is >-- great for application where Command_Line is not used. >-- > >function work return Integer is > > begin > return ( 0 ) ; -- no error status code > end work ; > > > >In <49ba30c9-a1e6-4346-8618-d256f87ac301@s31g2000vbp.googlegroups.com>, reinkor writes: >>I want to use Ada programs within unix/linux makefiles and shell >>scripts. >>Then these programs must sometimes exit with an exit code (error >>status) >>so execution of the Makefile/scripts halts. >> >>How I do this ? >> >>reinert Further to anon's reply, when your main program is a function, you can obviously return various other values. I think in UNIX world anything other than 0 means an error, but one can encode different error states of your own choosing eg: if (not File_Exists (file)) then return (3); -- File not found end if; if (not In_Correct_Format (file)) then return (15); -- Dodgy file end if; etc... Also see: http://www.faqs.org/docs/abs/HTML/exitcodes.html I have a few programs that do this, that are called from scripts that use the exit code to determine what to do next.