From nobody Tue Jun 27 17:00:21 2023 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 4Qr9v94vnQz4kjcn; Tue, 27 Jun 2023 17:00:21 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qr9v94V3dz3CfD; Tue, 27 Jun 2023 17:00:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687885221; 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=hYRVqqMpRbIfGlVQuMiyLRvETO1MPnfs8xNIbJKCgCM=; b=RuRjLlEq+HDfle2nBp/JzzgqIOW3oTvcDFDNq6i6Oznhel6Amnqw+CoDJENgHhlMz/7tvD PTIXzeoqtYXt47dp3pt/SykT0eg0nWXus/ToPcrTS3cjBK1QO1xhfpcN4RQgx1TxvsNuBY 9mWhCtdpx/PWVpBwS5FclqfWx7GzGPDCJQEXNeDIlQPSJUBBtp66JXof+VlrgRgR1tq4kv tTCkIPNVZguiMfl5DVaMSECakbD0Mvz+FqJ93C8Kue6jOzTXOa+YXYGZpRo7pSrXSeP8Hf chiLb8aq38qMJmNms37pMdUwAo1Rjys52ZI5oojAMclq/FpatSdeYNu+gbqGGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687885221; 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=hYRVqqMpRbIfGlVQuMiyLRvETO1MPnfs8xNIbJKCgCM=; b=KEbOkqRUUwkgSg9nsA7JJLCldyqB2vrBFkCav7MsuGGX6OpIkdh3DorrOqeNmP2bJAiJ5o LkHyAsD4+DVFKIwozQNlMe/mqpNDbaLlxFBYdDa9xlSlOzlUABDKG3mDxXmMPdlp1JhJsS 4vPccpvUVbckRYaPUDgybv+UwUPABZByanMskITPUBnpxomYYF3UM+RUkjBiAiPp21HGLW KLGzRHUnkro2T6WrjnnqrTDmu4kzt4pEqNzvBfEp8r+3/+9mf2EiYbzu8TdkW6rJ2vOLmK Q/VYOlS+bh5y4KO141Qc4J6XVyUp/ke/0UmqpmRt1LRA2k6/CgvoZvya/r15+g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687885221; a=rsa-sha256; cv=none; b=l3DF/JyvtrWhPBkw9Jm78X0s17HSM0JQ8zhIsipiK8Vd2G5HvtELyqmKtRchxzitTsAG1t xkKDSFq1JmlOaCR5eNlwyGXaqD3anvOPa/dPbZKFi+Uzoi4u0AVi3Xaq/t2/nJl7TcqrcT 4AOMi6E6ovlZfwu8yXrKEZfvkVrX841k3uqr+peGNkgZYa53zIFvYJ/1hF0J/hwXTF1ZTS sTQQEz6sVg1eURk+04S4oa+ieIEEDPNCp7MOgZaX3TYIOuFWzEmYU6o1zI1IbcXmPQteTv b99miAmDaRKu96b4tMJVr9CZFoRQxG/96Q8BhUmfGWgeNTVrplqRYF3oGeocTQ== 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 4Qr9v93FyDz10kT; Tue, 27 Jun 2023 17:00:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35RH0LFI081404; Tue, 27 Jun 2023 17:00:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35RH0L16081403; Tue, 27 Jun 2023 17:00:21 GMT (envelope-from git) Date: Tue, 27 Jun 2023 17:00:21 GMT Message-Id: <202306271700.35RH0L16081403@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: a227908571da - main - unzip: add -O/-I encoding support 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a227908571da056f66abb7263f965331303bf02f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=a227908571da056f66abb7263f965331303bf02f commit a227908571da056f66abb7263f965331303bf02f Author: Mingye Wang AuthorDate: 2023-06-27 16:54:12 +0000 Commit: Warner Losh CommitDate: 2023-06-27 16:55:26 +0000 unzip: add -O/-I encoding support These are for compatibility with the info-zip version of unzip. PR: 271657 Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/752 --- usr.bin/unzip/unzip.1 | 6 +++++- usr.bin/unzip/unzip.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/usr.bin/unzip/unzip.1 b/usr.bin/unzip/unzip.1 index 82e2c3a60ea0..436f1a928ce9 100644 --- a/usr.bin/unzip/unzip.1 +++ b/usr.bin/unzip/unzip.1 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 2, 2023 +.Dd June 27, 2023 .Dt UNZIP 1 .Os .Sh NAME @@ -34,6 +34,7 @@ .Sh SYNOPSIS .Nm .Op Fl aCcfjLlnopqtuvy +.Op { Fl O | Fl I No } Ar encoding .Op Fl d Ar dir .Op Fl x Ar pattern .Op Fl P Ar password @@ -62,6 +63,9 @@ Update existing. Extract only files from the zipfile if a file with the same name already exists on disk and is older than the former. Otherwise, the file is silently skipped. +.It Fl I Ar encoding +.It Fl O Ar encoding +Convert filenames from the specified encoding. .It Fl j Ignore directories stored in the zipfile; instead, extract all files directly into the extraction directory. diff --git a/usr.bin/unzip/unzip.c b/usr.bin/unzip/unzip.c index 578eaca9d772..1200aa53e7e3 100644 --- a/usr.bin/unzip/unzip.c +++ b/usr.bin/unzip/unzip.c @@ -59,6 +59,7 @@ static int C_opt; /* match case-insensitively */ static int c_opt; /* extract to stdout */ static const char *d_arg; /* directory */ static int f_opt; /* update existing files only */ +static char *O_arg; /* encoding */ static int j_opt; /* junk directories */ static int L_opt; /* lowercase names */ static int n_opt; /* never overwrite */ @@ -917,6 +918,9 @@ unzip(const char *fn) ac(archive_read_support_format_zip(a)); + if (O_arg) + ac(archive_read_set_format_option(a, "zip", "hdrcharset", O_arg)); + if (P_arg) archive_read_add_passphrase(a, P_arg); else @@ -999,7 +1003,7 @@ usage(void) { fprintf(stderr, -"Usage: unzip [-aCcfjLlnopqtuvyZ1] [-d dir] [-x pattern] [-P password] zipfile\n" +"Usage: unzip [-aCcfjLlnopqtuvyZ1] [{-O|-I} encoding] [-d dir] [-x pattern] [-P password] zipfile\n" " [member ...]\n"); exit(EXIT_FAILURE); } @@ -1010,7 +1014,7 @@ getopts(int argc, char *argv[]) int opt; optreset = optind = 1; - while ((opt = getopt(argc, argv, "aCcd:fjLlnopP:qtuvx:yZ1")) != -1) + while ((opt = getopt(argc, argv, "aCcd:fI:jLlnO:opP:qtuvx:yZ1")) != -1) switch (opt) { case '1': Z1_opt = 1; @@ -1030,6 +1034,9 @@ getopts(int argc, char *argv[]) case 'f': f_opt = 1; break; + case 'I': + case 'O': + O_arg = optarg; case 'j': j_opt = 1; break;