public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] support/shell-container.c: Add builtin exit
@ 2020-03-25 12:50 Adhemerval Zanella
0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2020-03-25 12:50 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5a5a3a3234bc220a5192d620e0cbc5360da46f14
commit 5a5a3a3234bc220a5192d620e0cbc5360da46f14
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Mar 24 15:40:36 2020 -0300
support/shell-container.c: Add builtin exit
Reviewed-by: DJ Delorie <dj@redhat.com>
Diff:
---
support/shell-container.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
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 }
};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-03-25 12:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 12:50 [glibc] support/shell-container.c: Add builtin exit Adhemerval Zanella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).