From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1827) id A6A6C386F02B; Tue, 12 May 2020 18:43:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6A6C386F02B Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tulio Magno Quites Machado Filho To: glibc-cvs@sourceware.org Subject: [glibc/ibm/2.30/master] support/shell-container.c: Add builtin exit X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/ibm/2.30/master X-Git-Oldrev: 55e77b7d8110bec77cef03078ad41cf617bd4ca8 X-Git-Newrev: 946ee0281a5a409c6e4af08fabcde9b03cf1624d Message-Id: <20200512184338.A6A6C386F02B@sourceware.org> Date: Tue, 12 May 2020 18:43:38 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 May 2020 18:43:38 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=946ee0281a5a409c6e4af08fabcde9b03cf1624d commit 946ee0281a5a409c6e4af08fabcde9b03cf1624d Author: Adhemerval Zanella Date: Tue Mar 24 15:40:36 2020 -0300 support/shell-container.c: Add builtin exit Reviewed-by: DJ Delorie (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 } };