From nobody Tue Apr 15 17:58:14 2025 X-Original-To: dev-commits-src-main@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 4ZcX2H2mjnz5tXlT; Tue, 15 Apr 2025 17:58: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 4ZcX2H1rDrz3k7Q; Tue, 15 Apr 2025 17:58:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744739895; 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=65quv4J9o/qXuOt9mDtd7S7EPrbci+eE7zTLX0Q/CQE=; b=rdw0/A4CmTV5Y+npl30xqahXsosuSi9xBmZCL6mci0NAzxOiW8FG23/G8D8/fRVfmioSMB M8FswK7/husCnjMmeOebPk0xfGi2qykMMSAGhYrFtjNIUKolb0apRsXmX2g13h77OTSpLO xJqrI9rn2xW2yCX6ylFT3tVCYUQhMtVHMJmG+i7oN0usGk2XYyZFKaBv6gEUN011jnieWg G0jZ4SQsV4JIJ7TwKBQXaZufvKYoixJik/B+uGhKxo2ErGZaCCRk1A6jrOH+m2NugnR7c7 kUav9x3nJ0G8aj6K/eSzDug3G7iNevhQ4l0++tf1ZQY6/xH9GxT7NsHuZliQHA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744739895; a=rsa-sha256; cv=none; b=A182P4S2qhNgRbBYVuyulnrv4az76DlYUCzHKvp4r3fE09TDPXFQQCSd0MzelGjzW637JY XSoyhUhfYaMX/nZIpVvhMkbgu1mqf+pzrGU4Z2S/9Uz7ot+4MV0sZLAZ1QcE/dS2oSuamY jJ8ffd+hz/AIH7ZA1OEEEsDNE0FOdFZA6MVxySkUmZsdMLOVliMkcU6F6nyn9SAxKSGxpL yFX+x82GyMI9ObVbveXV9YN8+gMSn/gNKRJaTRf4YVlAhH8Kwa1H5QCPk2+o8kiVGB/ZHe XHOh/iK2/6Anv6wh3oWjZW8lvJZ+UyR3S63bKIKp2J0yii3jtpGCimirF3Cvig== 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=1744739895; 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=65quv4J9o/qXuOt9mDtd7S7EPrbci+eE7zTLX0Q/CQE=; b=aXbublVl5HpVBDsm7wDOo1JcvsHAmxGwhpXR4meWKWmEBHYyJ5ndSmQ5iLm2KFKYBwgPmo qf97YWdEs0ZmHHYC1qVtHF0c51DNU69OxM/Ujsk+Jza8iHgo7d3dBg+ddOHF/KnwGpdzU3 8Q1xrVSsfDV3mwCk1VVpYaoiKq79fV9/ChqAtuXIZ8IJIx8qCgaqOvCzmdaXriwpJXjWmd V8MrsnBWEtB2FXbke2DRlVg1cK/w+8zXf1+hquH5sgmRQVRFeDDnwDyy5MvTSXSy6PQnqT ZEirNcuPOaDn1Gmu0ZHh7QXNj/AuPFxeRDBf8K3EpLOlbXGnPOWeTtcINqUPVQ== 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 4ZcX2H17QGzksn; Tue, 15 Apr 2025 17:58:15 +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 53FHwEOq059369; Tue, 15 Apr 2025 17:58:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53FHwEPu059366; Tue, 15 Apr 2025 17:58:14 GMT (envelope-from git) Date: Tue, 15 Apr 2025 17:58:14 GMT Message-Id: <202504151758.53FHwEPu059366@gitrepo.freebsd.org> 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=B8rgrav?= Subject: git: 7622e2d21a22 - main - cp: Improve error messages. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 7622e2d21a22f7af65a7145f91ef34179bb6ee03 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=7622e2d21a22f7af65a7145f91ef34179bb6ee03 commit 7622e2d21a22f7af65a7145f91ef34179bb6ee03 Author: Dag-Erling Smørgrav AuthorDate: 2025-04-15 17:57:28 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-04-15 17:57:38 +0000 cp: Improve error messages. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: allanjude, markj Differential Revision: https://reviews.freebsd.org/D49841 --- 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 823376964bd1..2b9c7531e4ca 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -214,7 +214,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: @@ -237,17 +237,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 @@ -339,8 +339,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;