From: Simon Wright <simon@pushface.org>
Subject: Re: Help with constructing an Ada Shell
Date: Fri, 30 Oct 2015 09:10:49 +0000
Date: 2015-10-30T09:10:49+00:00 [thread overview]
Message-ID: <lyvb9ovi06.fsf@pushface.org> (raw)
In-Reply-To: 9e1e5dc4-f5e6-4d8d-9677-1b66117d8a85@googlegroups.com
(1) I don't know why you want to use access String at all, at any rate
for the command (I see that Argument_List involves access to strings,
necessary in Ada to support ragged arrays).
(2) Spawn.Program_Name is the program to be spawned, Spawn.Arguments are
the arguments to that program, and shouldn't include the program unless
you want to execute it on itself.
(3) Wasn't there a discussion here recently about needing to supply the
full path to the program? (e.g. "/bin/ls" - I think you may have this
sorted already)
(4) The code you've posted doesn't compile.
The code below "works" provided the command you give it is "/bin/ls" - I
converted it into a procedure, & I haven't bothered with parsing the
command into Program_Name and Arguments, or with cleanup.
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with GNAT.Strings;
procedure Ada_Shell is
procedure Execute_System (Command : String);
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
IO.Put("ash> ");
declare
Input : constant String := IO.Get_Line;
begin
if Input = "quit" then
exit Main_Loop;
else
Execute_System (Input);
end if;
end;
end loop Main_Loop;
end Main;
procedure Execute_System (Command : String) is
Result : Integer;
Arguments : Argument_List := (1 => new String'("ada_shell.adb"));
begin
Spawn (Program_Name => Command,
Args => Arguments,
Output_File_Descriptor => Standout,
Return_Code => Result);
Put_Line(Integer'Image(Result));
end Execute_System;
begin
Main;
end Ada_Shell;
next prev parent reply other threads:[~2015-10-30 9:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-30 4:53 Help with constructing an Ada Shell annihilan
2015-10-30 8:37 ` Jacob Sparre Andersen
2015-11-03 0:47 ` Nick Gordon
2015-10-30 9:10 ` Simon Wright [this message]
2015-10-30 13:52 ` David Botton
2015-10-30 23:19 ` Xavier Petit
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox