about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-03-24 15:40:36 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-03-25 09:50:45 -0300
commit5a5a3a3234bc220a5192d620e0cbc5360da46f14 (patch)
tree0adbb16c66051f964df412e46856d7a5bf284b3a
parent5fce0e095bc413f908f472074c2235198cd76bf4 (diff)
downloadglibc-5a5a3a3234bc220a5192d620e0cbc5360da46f14.tar.gz
glibc-5a5a3a3234bc220a5192d620e0cbc5360da46f14.tar.xz
glibc-5a5a3a3234bc220a5192d620e0cbc5360da46f14.zip
support/shell-container.c: Add builtin exit
Reviewed-by: DJ Delorie <dj@redhat.com>
-rw-r--r--support/shell-container.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/support/shell-container.c b/support/shell-container.c
index d1112d4009..2f7405dc5f 100644
--- a/support/shell-container.c
+++ b/support/shell-container.c
@@ -135,6 +135,18 @@ copy_func (char **argv)
 
 }
 
+/* Emulate the 'exit' builtin.  The exit value is optional.  */
+static int
+exit_func (char **argv)
+{
+  int exit_val = 0;
+
+  if (argv[0] != 0)
+    exit_val = atoi (argv[0]) & 0xff;
+  exit (exit_val);
+  return 0;
+}
+
 /* This is a list of all the built-in commands we understand.  */
 static struct {
   const char *name;
@@ -143,6 +155,7 @@ static struct {
   { "true", true_func },
   { "echo", echo_func },
   { "cp", copy_func },
+  { "exit", exit_func },
   { NULL, NULL }
 };