From 8213431d222b56316e225a1f308b62a72fbb1faa Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Thu, 10 Mar 2011 21:23:11 +0800 Subject: [BUILTIN] Dotcmd should exit with zero when doing nothing Tim Allen wrote: > The POSIX specification for the dot command[1] states: > > EXIT STATUS > Returns the value of the last command executed, or a zero exit > status if no command is executed. > > If an empty file is sourced, then "no command is executed" I agree. Looking through "git log --patch src/main.c", though, I find v0.5.3~42 (Do not clobber exit status in dotcmd., 2005-03-03), which appears to have been meant to take care of the following case: $ cat printstatus.sh echo $? $ false $ . ./printstatus.sh 1 I wonder if the following on top might help (imitating evalcmd)? Signed-off-by: Jonathan Nieder Signed-off-by: Herbert Xu --- ChangeLog | 4 ++++ src/main.c | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d02fa9..8a832bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-10 Jonathan Nieder + + * Dotcmd should exit with zero when doing nothing. + 2011-03-10 Herbert Xu * Fix CTLESC clobbering by read(1). diff --git a/src/main.c b/src/main.c index 1735c67..b38dc27 100644 --- a/src/main.c +++ b/src/main.c @@ -202,6 +202,7 @@ cmdloop(int top) union node *n; struct stackmark smark; int inter; + int status = 0; int numeof = 0; TRACE(("cmdloop(%d) called\n", top)); @@ -235,6 +236,7 @@ cmdloop(int top) job_warning = (job_warning == 2) ? 1 : 0; numeof = 0; evaltree(n, 0); + status = exitstatus; } popstackmark(&smark); @@ -245,7 +247,7 @@ cmdloop(int top) } } - return 0; + return status; } @@ -325,9 +327,8 @@ dotcmd(int argc, char **argv) fullname = find_dot_file(argv[1]); setinputfile(fullname, INPUT_PUSH_FILE); commandname = fullname; - cmdloop(0); + status = cmdloop(0); popfile(); - status = exitstatus; } return status; } -- cgit 1.4.1 FreeBSD?id=e11cc40b9517fa9865b3cbe07ff4f540fd41456c'>unfollow)
Commit message (Expand)Author
2024-05-15Update to NetBSD 10.0 2066.5Štěpán Němec
2024-05-15Update to OpenBSD 7.5Štěpán Němec
2024-03-21Update to Linux man-pages 6.7 2065.7Štěpán Němec
2024-03-03Update to Linux man-pages 6.06 2065.06Štěpán Němec
2023-11-27Update to FreeBSD 14.0 2065.05Štěpán Němec
2023-10-16Update to OpenBSD 7.4 2064.25Kusoneko
2023-10-11Update to Linux man-pages 6.05 2064.15Štěpán Němec
2023-10-11Update to FreeBSD 13.2Štěpán Němec
2023-10-11Update to Linux man-pages 6.04, OpenBSD 7.3Štěpán Němec
2023-02-13Update to Linux man-pages 6.03 2063.93Štěpán Němec
2023-02-13Update to Linux man-pages 6.02Štěpán Němec
2022-11-01Update to Linux man-pages 6.01 2063.91Štěpán Němec
2022-10-21Update to OpenBSD 7.2 2063.9June McEnroe
2022-10-16NetBSD: include text.tar.xz man pages 2063.8Štěpán Němec
2022-10-16Update to Linux man-mages 6.00Štěpán Němec
2022-10-16Update to NetBSD 9.3Štěpán Němec
2022-09-18Make copyrights and AUTHORS consistentJune McEnroe
2022-07-27Update to FreeBSD 13.1 2062.83June McEnroe
2022-07-27openbsd: Include man pages from baseXX.tgzKeith Whitney
2022-05-08Update to OpenBSD 7.1 2062.73June McEnroe
2021-10-15Update to OpenBSD 7.0 2062.63June McEnroe
2021-08-29Update to Linux man-pages 5.13 2062.53Štěpán Němec
2021-08-26Update to NetBSD 9.2 2062.52June McEnroe
2021-08-26Support DESTDIR in install/uninstallJune McEnroe
2021-08-26Add version number generatorJune McEnroe
2021-08-22Add ISC license headerJune McEnroe
2021-08-22Update to Linux man-pages 5.12Štěpán Němec
2021-06-21Add manuals for macOS 11.3June McEnroe
2021-05-08Update to OpenBSD 6.9June McEnroe
2021-04-26Update to Linux man-pages 5.11June McEnroe
2021-04-26Update to FreeBSD 13.0June McEnroe
2021-01-27Completely rewrite how manuals are fetched and installedJune McEnroe
2020-12-14Update to man-pages-posix 2017-aJune McEnroe
2020-12-14Update to OpenBSD 6.8June McEnroe
2020-12-14Update to NetBSD 9.1June McEnroe
2020-12-14Update to man-pages 5.09June McEnroe
2020-12-14Update to FreeBSD 12.2June McEnroe
2020-06-08Update to OpenBSD 6.7June McEnroe
2020-05-04Add hack for macOS to search extra man sectionsJune McEnroe
2020-05-04Don't clear MANSECTJune McEnroe