revert between 56095 -> 55830 in arch
[AROS.git] / workbench / c / shellcommands / Quit.c
blobcf5d43848f1bda89438a66f64af0aedd3ea5d1d8
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /******************************************************************************
11 NAME
13 Quit
15 SYNOPSIS
17 RC/N
19 LOCATION
23 FUNCTION
25 Exits a script with the given return code. It's recommended that you
26 use the standard return codes 5, 10 and 20.
28 INPUTS
30 RC -- the return code. Defaults to 0.
32 RESULT
34 NOTES
35 If this command is called in a script that is executed from another
36 script, the entire series of nested scripts will stop.
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 ******************************************************************************/
48 #include <proto/dos.h>
49 #include <dos/dos.h>
50 #include <dos/dosextens.h>
51 #include <dos/rdargs.h>
52 #include "dos_commanderrors.h"
54 #include <aros/shcommands.h>
56 AROS_SH1(Quit, 41.1,
57 AROS_SHA(LONG *, ,RC,/N,NULL))
59 AROS_SHCOMMAND_INIT
61 struct CommandLineInterface *cli = Cli();
62 int retval = RETURN_OK;
65 if(cli && !cli->cli_Interactive)
67 struct FileHandle *fh = BADDR(cli->cli_CurrentInput);
69 fh->fh_Pos = fh->fh_End + 1; /* Simulate an EOF */
71 if(SHArg(RC) != NULL)
72 retval = (int)*SHArg(RC);
75 else
77 PrintFault(ERROR_SCRIPT_ONLY, "Quit");
78 retval = RETURN_FAIL;
81 return retval;
83 AROS_SHCOMMAND_EXIT