diff --git a/src/alire-os_lib.adb b/src/alire-os_lib.adb index beccd5f4..46e78f7d 100644 --- a/src/alire-os_lib.adb +++ b/src/alire-os_lib.adb @@ -177,10 +177,32 @@ package body Alire.OS_Lib is Code : constant Integer := Spawn (Command, Arguments, Understands_Verbose, Force_Quiet); begin if Code /= 0 then - raise Program_Error with "Exit code:" & Code'Image; + raise Program_Error with "Exit code:" & Code'Img; end if; end Spawn; + ------------------------ + -- Spawn_And_Redirect -- + ------------------------ + + procedure Spawn_And_Redirect (Out_File : String; + Command : String; + Arguments : String := ""; + Err_To_Out : Boolean := False) + is + File : constant File_Descriptor := Create_File (Out_File, Text); + Code : Integer; + begin + Spawn (Locate_In_Path (Command), + Argument_String_To_List (Arguments).all, + File, Code, Err_To_Out); + Close (File); + + if Code /= 0 then + raise Program_Error with "Exit code:" & Code'Img; + end if; + end Spawn_And_Redirect; + ------------------ -- Spawn_Bypass -- ------------------ diff --git a/src/alire-os_lib.ads b/src/alire-os_lib.ads index 6efa04e6..5dd52ef1 100644 --- a/src/alire-os_lib.ads +++ b/src/alire-os_lib.ads @@ -19,6 +19,11 @@ package Alire.OS_Lib is Arguments : String := ""); -- Direct launch, without any shenanigangs on output, for example for respawning the canonical version + procedure Spawn_And_Redirect (Out_File : String; + Command : String; + Arguments : String := ""; + Err_To_Out : Boolean := False); + type Folder_Guard (<>) is limited private; -- use this type in conjunction with Enter_Folder to ensure that -- the CWD is modified and restored when creating/destroying the Folder_Guard