runscript: 'shell' command return value incorrect

Eyal Birger eyal.birger at gmail.com
Wed Nov 11 13:02:44 UTC 2015


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:

=================

--- 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;
 }

====================

Please let me know if I had missed anything. Thanks!

Eyal.



More information about the minicom-devel mailing list