From nobody Thu Feb 13 23:49:04 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 4YvBjF3CwKz5nSK7; Thu, 13 Feb 2025 23:49:05 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YvBjF0TYGz46xq; Thu, 13 Feb 2025 23:49:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1739490545; 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=xgPLTt1vqwb4j9ltQqdoK8RnQBCZnGCMN5ad8N9VChE=; b=vBiCMZSg71p7zWVdaP6NkERx3z5f2LDQ+TsHxfWHB3Lad5tsw394yp4VpZHENKCs8Vvp3c 6g90/kWHzjFAsvSWwgmt4QVKMkultKRtEf0BkoEg0dkS+Me0+RZWrNfX2gzmalPyKEov1S ga9vy/lSw/c+VnwJYYil369D1Fx1CXJmH5zFLQSvuERemociIApMIQVgQX+CsXlvjEY7nD yTjKB1dySx4jbtqyRHJt7UWaU55yBDvpy5Obu3Lx67/Lvi5SM2PxLC2NZaww0hFHaSYlIW u07bQA5zcXADlskBGLLv/aVxpMzgY/ACoUDguTKmAq2ZmEUyP92mw01n+JFVCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1739490545; 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=xgPLTt1vqwb4j9ltQqdoK8RnQBCZnGCMN5ad8N9VChE=; b=Z0l3MX/sE3/hR5CSq8kaaYLOr+OARPKyc7rBTKy5rxZtA8JESKa8ymK8lvrIqGuaB4H8bR NJUxzGdnkwVaGc99CdSdp5eWpU2HLLPbu45RFNDqhded1pGJjFcn9A+kiCMqw8csFFW9vN CYuDqXSoBcOA3NvhNLbKuWbz+ORKQre2SWUzJgXkh2K9Ldo1N+PERWZaJVhQanvxitAl0i wNGt6dpfJpqkOQ/ztERUZMgkfRJjk0J+LZihRI+jRLiwW2cBc1cMgthHqa+HD7dZXHBaND 5knq/xRoPIOnzMCqqVCZCVpi1scpkF/PQRKsI6E7lkcuX/wpQorUNta8QSNBDA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1739490545; a=rsa-sha256; cv=none; b=MOzwas8tApNfa+Ku18RfkQjgLkB2M9yQjnV+r6CnGGdmsXhsrrUNtsMospuoGjJNTAOl0u 5OWO4kHVB5Q6nhSWNpTOVzni8O8+FlKFm4E+0zHfkl7Dw3Cx4R2bfZgYSDEJtyO9wkQG9i VzbbkWy3oAR9MTJxdyDO5e8L1w/ArZNS80keDaImNWOMK13VveaKydtQXa4IjqiBbOYv1P WUGXFX2BnEMkSovPyenmkTuJ85UbZzxfMVD1Qjs7XVyOUe6bb+FpHDnmXq3fFfaq99y0TN TzIZFHK612Twru6578TtygrZ2qOCsWN+dNe9UPez9ExZHeeLm4Tq5iQ7lmpdKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YvBjD6vxxz15Mg; Thu, 13 Feb 2025 23:49:04 +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 51DNn4gf028520; Thu, 13 Feb 2025 23:49:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51DNn4jN028517; Thu, 13 Feb 2025 23:49:04 GMT (envelope-from git) Date: Thu, 13 Feb 2025 23:49:04 GMT Message-Id: <202502132349.51DNn4jN028517@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jamie Gritton Subject: git: 3d11af1e595b - main - jls: fix the -q option to put quotes around all whitespace PR: 283414 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: jamie X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3d11af1e595b5a3646be370e33c4aa850dc62bb0 Auto-Submitted: auto-generated The branch main has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=3d11af1e595b5a3646be370e33c4aa850dc62bb0 commit 3d11af1e595b5a3646be370e33c4aa850dc62bb0 Author: Jamie Gritton AuthorDate: 2025-02-13 15:48:18 +0000 Commit: Jamie Gritton CommitDate: 2025-02-13 15:48:18 +0000 jls: fix the -q option to put quotes around all whitespace PR: 283414 --- usr.sbin/jls/jls.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/usr.sbin/jls/jls.c b/usr.sbin/jls/jls.c index e172c4698f57..2d173a29ac40 100644 --- a/usr.sbin/jls/jls.c +++ b/usr.sbin/jls/jls.c @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -515,13 +516,21 @@ quoted_print(int pflags, char *name, char *value) } /* - * The value will be surrounded by quotes if it contains spaces - * or quotes. + * The value will be surrounded by quotes if it contains + * whitespace or quotes. */ - qc = strchr(p, '\'') ? '"' - : strchr(p, '"') ? '\'' - : strchr(p, ' ') || strchr(p, '\t') ? '"' - : 0; + if (strchr(p, '\'')) + qc = '"'; + else if (strchr(p, '"')) + qc = '\''; + else { + qc = 0; + for (; *p; ++p) + if (isspace(*p)) { + qc = '"'; + break; + } + } if (qc && pflags & PRINT_QUOTED) xo_emit("{P:/%c}", qc);