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