From owner-svn-src-all@freebsd.org Sun Jul 15 09:14:31 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35089103335C; Sun, 15 Jul 2018 09:14:31 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DBB75805A8; Sun, 15 Jul 2018 09:14:30 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BD62440A5; Sun, 15 Jul 2018 09:14:30 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6F9EU68037531; Sun, 15 Jul 2018 09:14:30 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6F9EU0i037530; Sun, 15 Jul 2018 09:14:30 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201807150914.w6F9EU0i037530@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 15 Jul 2018 09:14:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336303 - head/bin/sh X-SVN-Group: head X-SVN-Commit-Author: jilles X-SVN-Commit-Paths: head/bin/sh X-SVN-Commit-Revision: 336303 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2018 09:14:31 -0000 Author: jilles Date: Sun Jul 15 09:14:30 2018 New Revision: 336303 URL: https://svnweb.freebsd.org/changeset/base/336303 Log: sh: Don't use padvance() for MAIL/MAILPATH Using padvance() requires undoing its append of '/' and prevents adjusting its '%' logic to allow most directories with '%' in PATH. No functional change is intended. Modified: head/bin/sh/mail.c Modified: head/bin/sh/mail.c ============================================================================== --- head/bin/sh/mail.c Sun Jul 15 05:29:39 2018 (r336302) +++ head/bin/sh/mail.c Sun Jul 15 09:14:30 2018 (r336303) @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); */ #include "shell.h" -#include "exec.h" /* defines padvance() */ #include "mail.h" #include "var.h" #include "output.h" @@ -72,9 +71,9 @@ void chkmail(int silent) { int i; - const char *mpath; + char *mpath; char *p; - char *q; + char *msg; struct stackmark smark; struct stat statb; @@ -83,22 +82,25 @@ chkmail(int silent) if (nmboxes == 0) return; setstackmark(&smark); - mpath = mpathset()? mpathval() : mailval(); + mpath = stsavestr(mpathset()? mpathval() : mailval()); for (i = 0 ; i < nmboxes ; i++) { - p = padvance(&mpath, ""); - if (p == NULL) - break; + p = mpath; if (*p == '\0') - continue; - for (q = p ; *q ; q++); - if (q[-1] != '/') - abort(); - q[-1] = '\0'; /* delete trailing '/' */ + break; + mpath = strchrnul(mpath, ':'); + if (*mpath != '\0') { + *mpath++ = '\0'; + if (p == mpath - 1) + continue; + } + msg = strchr(p, '%'); + if (msg != NULL) + *msg++ = '\0'; #ifdef notdef /* this is what the System V shell claims to do (it lies) */ if (stat(p, &statb) < 0) statb.st_mtime = 0; if (statb.st_mtime > mailtime[i] && ! silent) { - out2str(pathopt? pathopt : "you have mail"); + out2str(msg? msg : "you have mail"); out2c('\n'); } mailtime[i] = statb.st_mtime; @@ -106,7 +108,7 @@ chkmail(int silent) if (stat(p, &statb) < 0) statb.st_size = 0; if (statb.st_size > mailtime[i] && ! silent) { - out2str(pathopt? pathopt : "you have mail"); + out2str(msg? msg : "you have mail"); out2c('\n'); } mailtime[i] = statb.st_size;