Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide GNATPP message for user #7

Open
pjljvandelaar opened this issue Jun 24, 2022 · 2 comments
Open

Hide GNATPP message for user #7

pjljvandelaar opened this issue Jun 24, 2022 · 2 comments

Comments

@pjljvandelaar
Copy link
Collaborator

The rejuvenation library checks whether GNATPP is installed (accesible on the path).

In case Gnatpp is not installed, the behaviour is as desired.

In case GnatPP is installed, the user is shown the gnatpp version info.
This might confuse the user, so could you hide this message?

@pjljvandelaar
Copy link
Collaborator Author

@pjljvandelaar
Copy link
Collaborator Author

Suggestions are

  • wrapping redirection around you imported Sys routine, something like this:

    function Sys_Null (Arg : char_array) return Integer is
    begin
    return Sys (To_C (To_Ada (Arg) & " > /dev/null"));
    end Sys_Null;
    yet this is platform-dependent : nul [windows] and /dev/null [linux]

    • Could rely on the 'Target attribute in a .gpr file
    • using implementation-specific features of GNAT, there is a System.OS_Constants.Target_OS constant:
           type OS_Type is (Windows, Other_OS);
           Target_OS : constant OS_Type := Other_OS;
  • this routine from GNAT.OS_Lib:

    procedure Spawn
    (Program_Name : String;
    Args : Argument_List;
    Output_File_Descriptor : File_Descriptor;
    Return_Code : out Integer;
    Err_To_Out : Boolean := True);
    -- Similar to the procedure above, but redirects the output to the file
    -- designated by Output_File_Descriptor. If Err_To_Out is True, then the
    -- Standard Error output is also redirected.
    -- Return_Code is set to the status code returned by the operating system

  • one more alternative from GNAT.Expect:

    function Get_Command_Output
    (Command : String;
    Arguments : GNAT.OS_Lib.Argument_List;
    Input : String;
    Status : not null access Integer;
    Err_To_Out : Boolean := False) return String;
    -- Execute Command with the specified Arguments and Input, and return the
    -- generated standard output data as a single string. If Err_To_Out is
    -- True, generated standard error output is included as well. On return,
    -- Status is set to the command's exit status.

PS If you ever need more flexibility in creating child processes, you
might want to have a look at https://github.com/AdaCore/spawn, but it
will likely be an overkill for what you required on this TN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant