28653a
commit 5a5a3a3234bc220a5192d620e0cbc5360da46f14
28653a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
28653a
Date:   Tue Mar 24 15:40:36 2020 -0300
28653a
28653a
    support/shell-container.c: Add builtin exit
28653a
    
28653a
    Reviewed-by: DJ Delorie <dj@redhat.com>
28653a
28653a
diff --git a/support/shell-container.c b/support/shell-container.c
28653a
index e9eea64bca7e949d..aeaf6d2733abce61 100644
28653a
--- a/support/shell-container.c
28653a
+++ b/support/shell-container.c
28653a
@@ -135,6 +135,18 @@ copy_func (char **argv)
28653a
 
28653a
 }
28653a
 
28653a
+/* Emulate the 'exit' builtin.  The exit value is optional.  */
28653a
+static int
28653a
+exit_func (char **argv)
28653a
+{
28653a
+  int exit_val = 0;
28653a
+
28653a
+  if (argv[0] != 0)
28653a
+    exit_val = atoi (argv[0]) & 0xff;
28653a
+  exit (exit_val);
28653a
+  return 0;
28653a
+}
28653a
+
28653a
 /* This is a list of all the built-in commands we understand.  */
28653a
 static struct {
28653a
   const char *name;
28653a
@@ -143,6 +155,7 @@ static struct {
28653a
   { "true", true_func },
28653a
   { "echo", echo_func },
28653a
   { "cp", copy_func },
28653a
+  { "exit", exit_func },
28653a
   { NULL, NULL }
28653a
 };
28653a