feat: quit [exit_status], option support
Affecting process exit status.
This commit is contained in:
parent
faadb774b4
commit
b1a9e10be7
|
|
@ -31,7 +31,7 @@ Exit magic
|
|||
|
||||
<H3>Usage:</H3>
|
||||
<BLOCKQUOTE>
|
||||
<B>quit</B> [<B>-noprompt</B>]<BR><BR>
|
||||
<B>quit</B> [<B>exit_status</B>] [<B>-noprompt</B>]<BR><BR>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<H3>Summary:</H3>
|
||||
|
|
@ -46,8 +46,12 @@ Exit magic
|
|||
The Tcl <B>exit</B> command will <I>always</I> exit <B>magic</B>
|
||||
immediately, without prompting or cleanup or any other niceties. <P>
|
||||
|
||||
The <B>exit_status</B> option allows an exit status number in
|
||||
the range 0 to 255 to be indicated to the parent process. The
|
||||
default exit_status is 0 indicating success.<P>
|
||||
|
||||
With the <B>-noprompt</B> option, the interactive confirm prompt
|
||||
does not occur so any changes will be discarded.
|
||||
does not occur so any changes will be discarded. <P>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<H3>Implementation Notes:</H3>
|
||||
|
|
|
|||
|
|
@ -263,10 +263,11 @@ windQuitCmd(w, cmd)
|
|||
{
|
||||
clientRec *cr;
|
||||
bool checkfirst = TRUE;
|
||||
int exit_status = 0;
|
||||
|
||||
if (cmd->tx_argc == 2)
|
||||
if (cmd->tx_argc > 1)
|
||||
{
|
||||
if (!strcmp(cmd->tx_argv[1], "-noprompt"))
|
||||
if (!strcmp(cmd->tx_argv[cmd->tx_argc - 1], "-noprompt"))
|
||||
{
|
||||
checkfirst = FALSE;
|
||||
cmd->tx_argc--;
|
||||
|
|
@ -275,7 +276,21 @@ windQuitCmd(w, cmd)
|
|||
|
||||
if (cmd->tx_argc > 1)
|
||||
{
|
||||
TxError("Usage: quit [-noprompt]\n");
|
||||
int tmp;
|
||||
if (sscanf(cmd->tx_argv[cmd->tx_argc - 1], "%d", &tmp) == 1 && exit_status >= 0 && exit_status <= 255)
|
||||
{
|
||||
exit_status = tmp;
|
||||
cmd->tx_argc--;
|
||||
}
|
||||
else
|
||||
{
|
||||
TxError("Invalid exit_status: %s\n", cmd->tx_argv[cmd->tx_argc - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd->tx_argc > 1)
|
||||
{
|
||||
TxError("Usage: quit [exit_status] [-noprompt]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +303,7 @@ windQuitCmd(w, cmd)
|
|||
return;
|
||||
}
|
||||
|
||||
MainExit(0);
|
||||
MainExit(exit_status);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue