From nobody Mon Mar 2 08:52:11 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4fPXk93B50z6T6cm for ; Mon, 02 Mar 2026 08:52:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fPXk9140dz40dm for ; Mon, 02 Mar 2026 08:52:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772441537; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XWa+lGSsIrBqSDC0eK2SzksrMCMmiLqUbr7raBlcjU8=; b=ZLiIF62QP7eRWqIuGnBbjAql3+89Ouo1DfFS+GgI5ca6rvF71N4aUGEjlduz6rSD0fAjrq mVWQuIR9kyuSdnovuYF/0381TDme87NrgXPSBo7oviX7KHJ4rfWupewlVwKeay0KGoVf5a 77HvBtxyTPa3GeX8s92JMkvqXQ3WtyFDNR74QyZ2ds/u9r5RGHK5aoTYfS1hi/4kjIwoOU ROOsWsScnHTKYjOK3vVteELGlm07xM1UNAlm7o5elNInpOMmztqLO5GcMH5pMV2uOsDgLd OVEY5MHHL7KhvDlgPBC6gzP/kn7YGo4hSPAyaFt1wXRnGusyvRPzHmR91u1KQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772441537; a=rsa-sha256; cv=none; b=Wbdvui49ciCAGm9OeMlfRTRODYDK55bg5yoJJs1oSSNHNEIJ6JCr7Sg/JPMg6dIUbOhnDg 5h1ns8JvWpF4VML5xHC92AyNc7xkPMF/cpolkOzktsvFfpKhHXRiaTUCe6Boj7xeAIlDio 3zckI7ubJikxBuyOA4rgq0lKjC5D13PkcjAFHshsOnTJpRQjFRxL7AwsybUyuXgBazJJKf cikpbdZy0WAhad6QylF6ifveY251xHx/9y66PXLtd5/WFkRb1Aunk/uruwT4ADb6gZXRbD MYSRVF5E8mTzKY1HSRl1iiF45H7KPPw+CzoKejTnvlqapHhHcezuDriZUz6I8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772441537; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XWa+lGSsIrBqSDC0eK2SzksrMCMmiLqUbr7raBlcjU8=; b=PGrmhvGQzEjGEFdVbEbxZcIxyq0xBZejLMI397fK2P96tGHDvRIGa8hLUvxYOfLJv1EUxt ongUT4iFifcZqvOfXosC/SOvQ7wqsUMVGrbasV7wxq9kE6CRVgm/Y0TYkIXXgybVuW2U9Z cVoNrc19Nj9xMIXdfdXfqrfr/Z5GppoZPl2msXHBYAA/SvGg0HisTFDFoPNAux2v/QXy6z sE/7S+3ntIXXlI+/RDUYEYEyJHbMyUgeEmHUf3Nfuh+/fREUzW3e6wIJ17d6aHaNyW715l n+d45xSRBob8pBABHNDKjxjOa/UkQfBuMbf91f0riUkGAjHaccE5VRrR/RKXEQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fPXk86yqJzCBy for ; Mon, 02 Mar 2026 08:52:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 21594 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 02 Mar 2026 08:52:11 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: fe5341287c6c - main - diff3: Produce correct exit status List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fe5341287c6c9bacc18879b25ed72ceb42e1c811 Auto-Submitted: auto-generated Date: Mon, 02 Mar 2026 08:52:11 +0000 Message-Id: <69a54fbb.21594.1713b21f@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=fe5341287c6c9bacc18879b25ed72ceb42e1c811 commit fe5341287c6c9bacc18879b25ed72ceb42e1c811 Author: Dag-Erling Smørgrav AuthorDate: 2026-03-02 08:52:06 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-03-02 08:52:06 +0000 diff3: Produce correct exit status Use exit status 2 for errors, 1 only to indicate that differences were found between the inputs (in some operating modes). MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: ngie, bapt Differential Revision: https://reviews.freebsd.org/D55608 --- usr.bin/diff3/diff3.1 | 17 ++++++++++++++++- usr.bin/diff3/diff3.c | 26 +++++++++++++------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/usr.bin/diff3/diff3.1 b/usr.bin/diff3/diff3.1 index 9286a79e6ec6..8ca2d9f853af 100644 --- a/usr.bin/diff3/diff3.1 +++ b/usr.bin/diff3/diff3.1 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 23, 2022 +.Dd March 1, 2026 .Dt DIFF3 1 .Os .Sh NAME @@ -196,6 +196,21 @@ The lines beneath this notation are ranges of lines which are exclusively different in file .Va n . .El +.Sh EXIT STATUS +The +.Nm +utility exits with a status of 0 on success +and >1 if an error occurred. +Additionally, if the +.Fl A , +.Fl E , +.Fl L , +.Fl m , +or +.Fl X +flags were specified, +it exits with a status of 1 if conflicts were found. +.El .Sh SEE ALSO .Xr diff 1 , .Xr ed 1 , diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c index fce4d353af69..0f114163321f 100644 --- a/usr.bin/diff3/diff3.c +++ b/usr.bin/diff3/diff3.c @@ -202,7 +202,7 @@ strtoi(char *str, char **end) if ((end != NULL && *end == str) || num < 0 || num > INT_MAX || errno == EINVAL || errno == ERANGE) - err(1, "error in diff output"); + err(2, "error in diff output"); return (int)num; } @@ -267,7 +267,7 @@ readin(int fd, struct diff **dd) if (*p == ',') d = strtoi(p + 1, &p); if (*p != '\n') - errx(1, "error in diff output"); + errx(2, "error in diff output"); if (kind == 'a') a++; else if (kind == 'c') @@ -275,11 +275,11 @@ readin(int fd, struct diff **dd) else if (kind == 'd') c++; else - errx(1, "error in diff output"); + errx(2, "error in diff output"); b++; d++; if (b < a || d < c) - errx(1, "error in diff output"); + errx(2, "error in diff output"); (*dd)[i].old.from = a; (*dd)[i].old.to = b; (*dd)[i].new.from = c; @@ -287,7 +287,7 @@ readin(int fd, struct diff **dd) if (i > 0) { if ((*dd)[i].old.from < (*dd)[i - 1].old.to || (*dd)[i].new.from < (*dd)[i - 1].new.to) - errx(1, "diff output out of order"); + errx(2, "diff output out of order"); } } if (i > 0) { @@ -564,7 +564,7 @@ skip(int i, int from, const char *pr) for (n = 0; cline[i] < from - 1; n += j) { if ((line = get_line(fp[i], &j)) == NULL) - errx(1, "logic error"); + errx(2, "logic error"); if (pr != NULL) printf("%s%s", Tflag == 1 ? "\t" : pr, line); cline[i]++; @@ -595,7 +595,7 @@ duplicate(struct range *r1, struct range *r2) if (c == -1 && d == -1) break; if (c == -1 || d == -1) - errx(1, "logic error"); + errx(2, "logic error"); nchar++; if (c != d) { repos(nchar); @@ -652,7 +652,7 @@ printrange(FILE *p, struct range *r) return; if (r->from > r->to) - errx(1, "invalid print range"); + errx(2, "invalid print range"); /* * XXX-THJ: We read through all of the file for each range printed. @@ -900,27 +900,27 @@ increase(void) p = reallocarray(d13, newsz, sizeof(*p)); if (p == NULL) - err(1, NULL); + err(2, NULL); memset(p + szchanges, 0, incr * sizeof(*p)); d13 = p; p = reallocarray(d23, newsz, sizeof(*p)); if (p == NULL) - err(1, NULL); + err(2, NULL); memset(p + szchanges, 0, incr * sizeof(*p)); d23 = p; p = reallocarray(de, newsz, sizeof(*p)); if (p == NULL) - err(1, NULL); + err(2, NULL); memset(p + szchanges, 0, incr * sizeof(*p)); de = p; q = reallocarray(overlap, newsz, 1); if (q == NULL) - err(1, NULL); + err(2, NULL); memset(q + szchanges, 0, incr * 1); overlap = q; s = reallocarray(de_delta, newsz, sizeof(*s)); if (s == NULL) - err(1, NULL); + err(2, NULL); memset(s + szchanges, 0, incr * sizeof(*s)); de_delta = s; szchanges = newsz;