runscript: 'shell' command return value incorrect

Adam Lackorzynski adam at os.inf.tu-dresden.de
Sun Nov 15 21:41:29 UTC 2015


Hi,

On Wed Nov 11, 2015 at 15:02:44 +0200, Eyal Birger wrote:
> Hi,
> 
> When using the 'shell' directive ('!'), the $? variable value seems incorrect.
> 
> Looking at the code, it seems it is set to the return value of the
> system(3) call,
> which is similar to the wait(2) return value and thus should be
> accessed via WIF...() macros as
> done in the 'pipedshell' directive.
> 
> Therefore I would like to suggest the following change:

Looks good to me. Committed. Thanks.

> =================
> 
> --- a/src/script.c
> +++ b/src/script.c
> @@ -635,7 +635,13 @@ int expect(char *text)
>   */
>  int shell(char *text)
>  {
> -  laststatus = system(text);
> +  int status = system(text);
> +  if (WIFEXITED(status))
> +    laststatus = WEXITSTATUS(status);
> +  else if (WIFSIGNALED(status))
> +    laststatus = WTERMSIG(status);
> +  else
> +    laststatus = status;
>    return OK;
>  }
> 
> ====================


Adam
-- 
Adam                 adam at os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/



More information about the minicom-devel mailing list