prism2.device: Compiler delint
[AROS.git] / workbench / c / shellcommands / FailAt.c
blob4754122b288304f4dd382fc443cd5a8ad63d897f
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: FailAt - Set the failure level of a process
6 Lang: English
7 */
9 /**************************************************************************
11 NAME
12 FailAt
14 FORMAT
15 FailAt <limit>
17 SYNOPSIS
18 RCLIM/N
20 LOCATION
23 FUNCTION
24 FailAt sets the return code limit of the current shell script. If
25 any command returns with a failure code of this value or higher
26 the script shall abort.
28 Common failure codes are:
29 0 - No error
30 5 - Warning
31 10 - Error
32 20 - Failure
34 The normal value for the return code limit is 10.
36 EXAMPLE
37 If we have a script with the commands
39 Copy RAM:SomeFile DF0:
40 Echo "Done!"
42 and the file RAM:SomeFile does not exist, the Copy command will
43 return with:
45 Copy: object not found
46 Copy: returned with error code 20
48 and the script will abort. However if you include the command
50 FailAt 21
52 then the script will complete since the return code from Copy is
53 less than the return code limit.
55 **************************************************************************/
57 #include <exec/types.h>
58 #include <exec/tasks.h>
59 #include <dos/dosextens.h>
60 #include <dos/rdargs.h>
61 #include <proto/exec.h>
62 #include <proto/dos.h>
63 #include <utility/tagitem.h>
65 #include <aros/shcommands.h>
67 AROS_SH1H(FailAt, 41.1, "Set the return code failure limit of the current script",
68 AROS_SHAH(LONG *, , RCLIM,/N, NULL, "The new return code limit"))
70 AROS_SHCOMMAND_INIT
72 struct CommandLineInterface *cli = Cli();
75 if (cli == NULL)
77 return RETURN_FAIL;
80 /* Write current fail level */
81 if (SHArg(RCLIM) == NULL)
83 VPrintf("Fail limit: %ld\n", (IPTR *)&cli->cli_FailLevel);
85 /* Set new fail level */
86 else
88 cli->cli_FailLevel = *SHArg(RCLIM);
91 return RETURN_OK;
93 AROS_SHCOMMAND_EXIT