Do not try to get stack pointer from invalid ESP field, which coincidentally
[AROS.git] / rom / dos / execute.c
bloba66ac7fabb4d43554910fde5b9897ceb4d34285d
1 /*
2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Execute a CLI command
6 Lang: English
7 */
9 #include "dos_intern.h"
10 #include <dos/dosextens.h>
11 #include <utility/tagitem.h>
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH3(LONG, Execute,
20 /* SYNOPSIS */
21 AROS_LHA(CONST_STRPTR, string, D1),
22 AROS_LHA(BPTR , input , D2),
23 AROS_LHA(BPTR , output, D3),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 37, Dos)
28 /* FUNCTION
30 Execute a CLI command specified in 'string'. This string may contain
31 features you may use on the shell commandline like redirection using >,
32 < or >>. Execute() doesn't return until the command(s) that should be
33 executed are finished.
34 If 'input' is not NULL, more commands will be read from this stream
35 until end of file is reached. 'output' will be used as the output stream
36 of the commands (if output is not redirected). If 'output' is NULL the
37 current window is used for output -- note that programs run from the
38 Workbench doesn't normally have a current window.
40 INPUTS
42 string -- pointer to a NULL-terminated string with commands
43 (may be NULL)
44 input -- stream to use as input (may be NULL)
45 output -- stream to use as output (may be NULL)
47 RESULT
49 Boolean telling whether Execute() could find and start the specified
50 command(s). (This is NOT the return code of the command(s).)
52 NOTES
54 EXAMPLE
56 BUGS
58 SEE ALSO
60 SystemTagList()
62 INTERNALS
64 To get the right result, the function ExecCommand() (used by both Execute()
65 and SystemTagList()) uses NP_Synchronous to wait for the commands to
66 finish. This is not the way AmigaOS does it as NP_Synchronous is not
67 implemented (but defined).
69 *****************************************************************************/
71 AROS_LIBFUNC_INIT
73 LONG result;
74 struct TagItem tags[] =
76 { SYS_Asynch, FALSE },
77 { SYS_Background, FALSE },
78 { SYS_Input, (IPTR)input },
79 { SYS_Output, (IPTR)output },
80 { SYS_Error, (IPTR)NULL },
81 { TAG_DONE, 0 }
85 result = SystemTagList(string, tags);
87 if(result == 0)
88 return DOSTRUE;
89 else
90 return DOSFALSE;
92 AROS_LIBFUNC_EXIT
93 } /* Execute */