aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-03-24 15:40:36 -0300
committerAndreas K. Hüttel <dilfridge@gentoo.org>2020-04-12 00:52:18 +0300
commit9d709a1a8b2ddfb0f46c083b9b24af6d3c3ea9fe (patch)
tree32a30f66dbf1d8099d7c21076ca3105c9e3b4936
parentsupport/shell-container.c: Return 127 if execve fails (diff)
downloadglibc-9d709a1a8b2ddfb0f46c083b9b24af6d3c3ea9fe.tar.gz
glibc-9d709a1a8b2ddfb0f46c083b9b24af6d3c3ea9fe.tar.bz2
glibc-9d709a1a8b2ddfb0f46c083b9b24af6d3c3ea9fe.zip
support/shell-container.c: Add builtin exit
Reviewed-by: DJ Delorie <dj@redhat.com> (cherry picked from commit 5a5a3a3234bc220a5192d620e0cbc5360da46f14) (cherry picked from commit 2448ba1d724bec8cd162084fc51aaecea3929727)
-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 0f4568ed0c..6540f8ac47 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 }
};