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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!proxad.net!feeder1-2.proxad.net!cleanfeed2-b.proxad.net!nnrp2-1.free.fr!not-for-mail Date: Sat, 31 Oct 2015 00:19:16 +0100 From: Xavier Petit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Help with constructing an Ada Shell References: <9e1e5dc4-f5e6-4d8d-9677-1b66117d8a85@googlegroups.com> In-Reply-To: <9e1e5dc4-f5e6-4d8d-9677-1b66117d8a85@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <5633faf4$0$3023$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 31 Oct 2015 00:19:16 CET NNTP-Posting-Host: 78.217.21.11 X-Trace: 1446247156 news-2.free.fr 3023 78.217.21.11:35257 X-Complaints-To: abuse@proxad.net Xref: news.eternal-september.org comp.lang.ada:28144 Date: 2015-10-31T00:19:16+01:00 List-Id: Hello, I would suggest you to learn Ada with more easy and abstract stuff, not shells ^^ which are platform dependent and related to the Unix/C philosophy. GNAT provides OS abstraction but I think that dealing with process spawning is not the best way to learn Ada. Here a working example of what you wanna do, based on previous answers. (Sorry for my terrible english) with Ada.Text_IO, GNAT.OS_Lib; procedure Ada_Shell is procedure Execute_System (Command : String) is use GNAT.OS_Lib; List : String_List_Access := Argument_String_To_List (Command); Exec_Path : String_Access := Locate_Exec_On_Path (List (1).all); Success : Boolean; begin if Exec_Path /= null then Spawn (Program_Name => Exec_Path.all, Args => List (2 .. List'Last), Success => Success); Free (Exec_Path); else Ada.Text_IO.Put_Line ("Command not found"); end if; Free (List); end Execute_System; begin Main : loop Ada.Text_IO.Put ("ash> "); declare Input : constant String := Ada.Text_IO.Get_Line; begin exit Main when Input = "exit"; if Input'Length > 0 then Execute_System (Command => Input); end if; end; end loop Main; exception when Ada.Text_IO.End_Error => null; -- Handling [Ctrl]-[D] end Ada_Shell; -- Xavier Petit