From 845359d842aa55fb1f0d7b729703c09b73701d0b Mon Sep 17 00:00:00 2001 From: neil Date: Thu, 25 Dec 2014 05:51:16 +0000 Subject: [PATCH] - Print out an error when the stack for a command can't be allocated (like AOS3 does). - Grab error code from IoErr() immediately after RunCommand(). - Removed command-style AutoDoc, since this isn't a command, and it was mostly empty. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@49870 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/c/Shell/Shell.c | 63 ++++++----------------------------------------- 1 file changed, 7 insertions(+), 56 deletions(-) diff --git a/workbench/c/Shell/Shell.c b/workbench/c/Shell/Shell.c index 2800be75bd..00b69e8011 100644 --- a/workbench/c/Shell/Shell.c +++ b/workbench/c/Shell/Shell.c @@ -1,60 +1,7 @@ /* Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ - - The shell program. - */ - -/****************************************************************************** - - NAME - - Shell - - SYNOPSIS - - LOCATION - - L:UserShell-Seg - - FUNCTION - - Start a shell (interactive or background). - - INPUTS - - RESULT - - HISTORY - - Aug 2011 - Use AOS startup packet mechanisms - - Sep 2010 - rewrite of the convertLine function. - - Jul 2010 - improved handling of $ and `: things like cd SYS:Olle/$pelle - work now. Non-alphanumerical var-names must be enclosed in - braces. - - Feb 2008 - initial support for .key/bra/ket/dot/dollar/default. - - EXAMPLE - - Resident Shell L:UserShell-Seg SYSTEM PURE ADD - - Configures the default User Shell to this shell - - BUGS - - SEE ALSO - - Execute, NewShell, Run - - INTERNALS - - The prompt support does not use SetCurrentDirName() as this function - has improper limitations. More or less the same goes for GetProgramName(). - -******************************************************************************/ +*/ /* TODO: Break support (and +(0L) before execution) -- CreateNewProc()? @@ -533,6 +480,7 @@ static LONG executeLine(ShellState *ss, STRPTR commandArgs) mem_before = FindVar("__debug_mem", LV_VAR) ? AvailMem(MEMF_ANY) : 0; cli->cli_ReturnCode = RunCommand(seglist, defaultStack, cmd, len); + error = (cli->cli_ReturnCode == RETURN_OK) ? 0 : IoErr(); /* Update the state of the cli_Interactive field */ setInteractive(cli, ss); @@ -569,11 +517,14 @@ static LONG executeLine(ShellState *ss, STRPTR commandArgs) Printf("Memory leak of %lu bytes\n", mem_before - mem_after); } - D(bug("[Shell] returned %ld (%ld): %s\n", cli->cli_ReturnCode, IoErr(), command)); - error = (cli->cli_ReturnCode == RETURN_OK) ? 0 : IoErr(); + D(bug("[Shell] returned %ld (%ld): %s\n", cli->cli_ReturnCode, + error, command)); pr->pr_Task.tc_Node.ln_Name = oldtaskname; unloadCommand(ss, module, homeDirChanged, residentCommand); + /* If command couldn't be started, explain why */ + if (cli->cli_ReturnCode == -1) + PrintFault(error, command); } else { -- 2.11.4.GIT