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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.140.196.76 with SMTP id r73mr4663717qha.3.1446180800891; Thu, 29 Oct 2015 21:53:20 -0700 (PDT) X-Received: by 10.182.210.134 with SMTP id mu6mr67458obc.20.1446180800855; Thu, 29 Oct 2015 21:53:20 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!c107no3308689qgd.1!news-out.google.com!fs1ni2503igb.0!nntp.google.com!i2no634846igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 29 Oct 2015 21:53:20 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=96.32.253.162; posting-account=TqGH2woAAAAOL7cuGUYe_Weq4IpyHmTd NNTP-Posting-Host: 96.32.253.162 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9e1e5dc4-f5e6-4d8d-9677-1b66117d8a85@googlegroups.com> Subject: Help with constructing an Ada Shell From: annihilan@gmail.com Injection-Date: Fri, 30 Oct 2015 04:53:20 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:28120 Date: 2015-10-29T21:53:20-07:00 List-Id: Okay. So I've been trying to learn Ada recently, which unfortunately means = that my question isn't going to be very sophisticated. I have the following= code: with Ada.Text_IO; use Ada.Text_IO; with GNAT.OS_Lib; use GNAT.OS_Lib; with GNAT.Strings; package body Ada_Shell is Input : aliased String :=3D (1 .. 255 =3D> ' '); Last : Integer; procedure Main is package IO renames Ada.Text_IO; begin IO.Put_Line("Welcome to ash! This is an extreme work in progress."); Main_Loop: loop Input :=3D (others=3D> ' '); IO.Put("ash> "); IO.Get_Line(Input, Last); if Input(Input'First..Last) =3D "quit" then exit Main_Loop; else Execute_System; end if; end loop Main_Loop; end Main; =20 procedure Execute_System is Result : Integer; Arguments : Argument_List :=3D (1 =3D> Input'Access); begin Spawn (Program_Name =3D> Input, -- truncate strings or Input(Input'Fi= rst..Last)?? Args =3D> Arguments, Output_File_Descriptor =3D> Standout, Return_Code =3D> Result); -- for Index in Arguments'Range loop -- Free(Arguments(Index)); -- end loop; Put_Line(Integer'Image(Result)); end Execute_System; end Ada_Shell; This code is executed by a simple procedure that calls the Main loop of the= package. I don't know if there's a "better" way to make a repeating main l= oop like this, but I couldn't contrive a better solution.=20 Besides, this code does not work. It compiles, sure, but it doesn't work. N= o matter what command is passed at the prompt, a return value of 1 is given= .=20 Things I have tried that work: hardcoding the program at Spawn(Program_Name=3D>"/bin/ls") or similar Things I have tried that have not worked: Having Execute_System be in a separate file, and having its signature as Ex= ecute_System(Command:access String) (this worked especially poorly, bringin= g in aliasing problems that I couldn't solve. I really don't know why this doesn't work. The reason that the result code = and command line are global was to eliminate "non-local pointer references = local object" and "implicit conversion of anonymous access formal" errors. = I haven't tried uncommenting the Free block since I fixed everything, thoug= h. I would massively appreciate any help that could be given to me. I don't re= ally have any clue at all what's going on.