public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tulio Magno Quites Machado Filho <tuliom@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/ibm/2.30/master] support/shell-container.c: Add builtin exit
Date: Tue, 12 May 2020 18:43:38 +0000 (GMT)	[thread overview]
Message-ID: <20200512184338.A6A6C386F02B@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=946ee0281a5a409c6e4af08fabcde9b03cf1624d

commit 946ee0281a5a409c6e4af08fabcde9b03cf1624d
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>
    
    (cherry picked from commit 5a5a3a3234bc220a5192d620e0cbc5360da46f14)

Diff:
---
 support/shell-container.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/support/shell-container.c b/support/shell-container.c
index abf40e4167..99a0ff7ca5 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 }
 };


                 reply	other threads:[~2020-05-12 18:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200512184338.A6A6C386F02B@sourceware.org \
    --to=tuliom@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).