2 * Copyright 1995, 2003 Perforce Software. All rights reserved.
4 * This file is part of Perforce - the FAST SCM System.
8 * RunCommand() -- Just run a command and capture its output
10 * RunCommand is a StrBuf that can run its contents as an OS command.
11 * It has static members for passing in a command wholesale, and methods
12 * for quoting args to protect them from the shell.
14 * Except where notes, these are implemented for UNIX, NT, VMS, MAC,
18 * RunCommand::Run() - run the command
19 * Used by the client for launching editor, diff.
21 * RunCommand::RunOut() - run the command, capturing stdout
22 * Used to run triggers for 'p4 submit'.
23 * Not implemented for MAC, VMS.
25 * RunCommand::RunInWindow() - create a window to run the command
26 * Used by p4web for launching editor, resolve.
27 * Not implemented for MAC, VMS.
29 * RunCommand::RunChild() - launch a subprocess whose stdin/stdout
32 * RunCommand::AddArg() - add a single argument
33 * RunCommand::SetArgs() - clear the command buffer and add args
36 class RunCommand
: public StrBuf
{
39 static int Run( const StrPtr
&cmd
, Error
*e
);
40 static int RunOut( const StrPtr
&cmd
, StrBuf
&result
, Error
*e
);
41 static int RunInWindow( const StrPtr
&cmd
, Error
*e
);
42 static int RunChild( const StrPtr
&cmd
, int rfd
, int wfd
, Error
*e
);
45 { return Run( *this, e
); }
47 int RunOut( StrBuf
&r
, Error
*e
)
48 { return RunOut( *this, r
, e
); }
50 int RunInWindow( Error
*e
)
51 { return RunInWindow( *this, e
); }
53 int RunChild( int rfd
, int wfd
, Error
*e
)
54 { return RunChild( *this, rfd
, wfd
, e
); }
56 void SetArgs( int argc
, const char **argv
);
57 void AddArg( const char *arg
);