From nobody Mon Apr 21 17:41:14 2025 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 4ZhCMv0TVMz5snJt; Mon, 21 Apr 2025 17:41:15 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZhCMt3qrBz3SHg; Mon, 21 Apr 2025 17:41:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745257274; 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=2O43EYDkZemp0voP7FUXdWLy9OW3dB/PyeKoIOxoWts=; b=Y1tdyctWQObZ5XLgzqAnNs0Hpb1GvB5WdGGHQD9BapcYQKK8tjZvaqK34ZHLnvNQILxu9h YlJ3JPNA08AkSa16k/Eo1I8lS+4fV5C3I8vFk8F0r5pLKim5bJnsJV/tIb6llnbFibV6A5 /Y82d0dflyvjgwIhofUjdp9ITw6+LY4HvkSZwuvzYGVPd6rdRMRW7uY7aYTo3IgLjeeXp3 3Lr/2g+lH63regztKOfpJh5O69dXbS08BMgUqwzntzDKksJRaib3ygnGYgeeEx8EbtmgUc OABu+7KErE+DCwsyze28vdPYYtiGb7xWhMb22NmpTFoC/08iKFYl5/QkmoP6CA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1745257274; a=rsa-sha256; cv=none; b=Vu3TVfpBSlEHsf7PWGYq0HQB3yKemne7AG8Tsxvj3KbuhBULEFTWUr/Rn70AxqaXp7M9m2 AHeeCvHFIKV6jka9djdw5iP3VKd+LV00jJXgNYC28kd9sm2FyBWZ7RogUt0Jpa2t6B//MT rxGq0US+8DUj642t95OjnmJMjLW6EtUiRoMFjv0FmJjIiBsd0Vv/PPksNCy/RVF7mm4Ffv EDWMLeV1wLyhjvvZ02bP1ovgoXYxf2vTdbyka2oreP3HlgrlWSV0oHmeySENNGzcOlcJIa PBbKKaqUvJOe+lwuF3yT26H9OVZAWJpmZ49bq2bCmnLwo1Zc1U3mFWPN9BAMMg== 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=1745257274; 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=2O43EYDkZemp0voP7FUXdWLy9OW3dB/PyeKoIOxoWts=; b=kwOI/kS0hbHedWf9Xlo98Iz1reVCwCe5DEhSern95Nbbncx0vuTBk8Kcco3CsKu2K5WLYF HEzouBJgJnw5DlXBvBXVpI0PrRepIPZR7kOZl0Rv6dnPm4jTRFIaH98eMJhDxwI+FX5/Zi HXTcBX61nXg7uJyQwGXnCkOSfJNOMS1dxhPj9KAkYL/yspkOoxuD6g3e9AXBf05+oq8ukq comRkRIpY2RP1Q/Yhd0Bj9RjcuGHU3rVermKk6W33rTgKJdKLlo8LBodqxr7A95OSwY1dm T62t7nTxhyc5wnDT/d4bd94qaFz1sA68jwTbpeZRFKmX4QMPRutQi7HAUjq47w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZhCMt3Rlwz10R0; Mon, 21 Apr 2025 17:41:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53LHfEQH036157; Mon, 21 Apr 2025 17:41:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53LHfEhC036153; Mon, 21 Apr 2025 17:41:14 GMT (envelope-from git) Date: Mon, 21 Apr 2025 17:41:14 GMT Message-Id: <202504211741.53LHfEhC036153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: c6cb1b2ee506 - stable/13 - cp: Improve error messages. 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/stable/13 X-Git-Reftype: branch X-Git-Commit: c6cb1b2ee5065ea2eaf725c09b45fd7a249bb4dc Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=c6cb1b2ee5065ea2eaf725c09b45fd7a249bb4dc commit c6cb1b2ee5065ea2eaf725c09b45fd7a249bb4dc Author: Dag-Erling Smørgrav AuthorDate: 2025-04-15 17:57:28 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-04-20 08:00:24 +0000 cp: Improve error messages. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: allanjude, markj Differential Revision: https://reviews.freebsd.org/D49841 (cherry picked from commit 7622e2d21a22f7af65a7145f91ef34179bb6ee03) --- bin/cp/cp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/cp/cp.c b/bin/cp/cp.c index a8c57308ae96..79a808059536 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -227,7 +227,7 @@ main(int argc, char *argv[]) * Case (1). Target is not a directory. */ if (argc > 1) - errx(1, "%s is not a directory", to.p_path); + errc(1, ENOTDIR, "%s", to.p_path); /* * Need to detect the case: @@ -250,17 +250,17 @@ main(int argc, char *argv[]) type = FILE_TO_FILE; if (have_trailing_slash && type == FILE_TO_FILE) { - if (r == -1) { - errx(1, "directory %s does not exist", - to.p_path); - } else - errx(1, "%s is not a directory", to.p_path); + if (r == -1) + errc(1, ENOENT, "%s", to.p_path); + else + errc(1, ENOTDIR, "%s", to.p_path); } - } else + } else { /* * Case (2). Target is a directory. */ type = FILE_TO_DIR; + } /* * For DIR_TO_DNE, we could provide copy() with the to_stat we've @@ -368,8 +368,8 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat) base = (p == NULL) ? 0 : (int)(p - curr->fts_path + 1); - if (!strcmp(&curr->fts_path[base], - "..")) + if (strcmp(curr->fts_path + base, "..") + == 0) base += 1; } else base = curr->fts_pathlen;