comp.lang.ada
 help / color / mirror / Atom feed
From: Rob Norris <firstname.lastname@baesystems.com>
Subject: Re: How to exit an Ada program with (unix shell) error code?
Date: Tue, 05 May 2009 11:49:54 +0100
Date: 2009-05-05T11:49:54+01:00	[thread overview]
Message-ID: <hm5005l6atme5c0ucjsvmt2h3dvpc3mjj6@4ax.com> (raw)
In-Reply-To: xqELl.194949$4m1.167184@bgtnsc05-news.ops.worldnet.att.net

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 <reinkor@gmail.com> 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.



  reply	other threads:[~2009-05-05 10:49 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-04  9:08 How to exit an Ada program with (unix shell) error code? reinkor
2009-05-04  9:17 ` Samuel Tardieu
2009-05-04  9:26   ` reinkor
2009-05-04  9:31     ` Ludovic Brenta
2009-05-04  9:47       ` reinkor
2009-05-04  9:54         ` Martin
2009-05-04 11:38           ` sjw
2009-05-04 10:07       ` stefan-lucks
2009-05-04 13:42     ` Robert A Duff
2009-05-04 16:19       ` Martin
2009-05-07  9:48         ` anon
2009-05-04 16:09 ` anon
2009-05-05 10:49   ` Rob Norris [this message]
2009-05-05 11:15     ` Georg Bauhaus
2009-05-05 11:43   ` Martin
2009-05-05 14:57     ` Adam Beneschan
2009-05-05 15:34       ` Jean-Pierre Rosen
2009-05-06 15:28         ` Adam Beneschan
2009-05-06 22:10           ` Randy Brukardt
2009-05-07  9:08           ` anon
2009-05-07 10:01             ` Georg Bauhaus
2009-05-07 11:22               ` anon
2009-05-07 12:08                 ` Martin
2009-05-07 13:34                 ` Georg Bauhaus
2009-05-07 16:26             ` Adam Beneschan
2009-05-08 10:17               ` anon
2009-05-12 22:55                 ` Adam Beneschan
2009-05-14  2:55                   ` anon
2009-05-14  8:04                     ` Martin
2009-05-14  8:39                     ` Martin
2009-05-14  8:45                       ` Martin
2009-05-14  9:34                       ` Ludovic Brenta
2009-05-14 10:05                         ` Martin
2009-05-14 12:38                           ` Georg Bauhaus
2009-05-14 15:34                     ` Adam Beneschan
2009-05-15 10:20                       ` anon
2009-05-15 11:19                         ` Martin
2009-05-05 20:48       ` anon
2009-05-05 21:01         ` Adam Beneschan
2009-05-06 11:30         ` Hibou57 (Yannick Duchêne)
2009-05-05 20:31     ` anon
2009-05-05 21:27       ` Martin
2009-05-06  8:41         ` anon
2009-05-06  9:14           ` Martin
2009-05-06 11:41             ` Georg Bauhaus
replies disabled

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