From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8872 invoked from network); 9 Jan 2024 18:30:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Jan 2024 18:30:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1704825045; b=Snf0dtRiMNz1P1YEcJ62TlJjEdOBhb3fQ0nT6ccmIPtmKMYdhVX1CGzn6oHqu/TsszrJkjv8k0 b8dcJif2QhCp3kLBbxYQL3iFr/dQKoXaYrwzGaLaMOVQRSglOstSjUgGojSIxUKZuv8nGZfiHg QItr3OPfBh+DEVIxxE1To5iDHlI4xercCfCR2cLS6zUa2ZIOeUd5RXXwdutlfqpUXyDcsX9RwK uqVNODImruY+3iKY+7NU+L077X/K342O4NKKRZoqm+6safkVpiHv1+N2oAe2CY/a4pT2vsqCZZ p9LcVF8TFL58PzW4ukZI7SEDAgjT9xSE8qo0dqLi1ruQTQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1704825045; bh=i879fJzBWmp4QgNqqn4JUK9aMjyVhEGEL+/M/lDasTA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=qN5bSEosG0Nu7nGYxD7uUQ7JrAStDs/ECOjDBvOWmF6LbInghl7c6dxb9iXzweAzW6q5mIyUIH 5hi44ez1SrZmkqSlTic+mdP2Bbet35d0ikrhe9+JzyfFDpsf8+0KR7fZxBt6zpL8NJmfwEzBdO MtNr33cMVtRnTX+9tpiG+mQ/17DqN3xL0NAc1eS7u/V7O3LEDkBknr6VAOxeHfWOO0FNm3Oa0G 9Y1dmCveZOooJbFoAo6+mbyeJVogvVu+JxGNX4kLrhQJujailWu4m2Ff+9+/YQ+3JYiKlPKxq0 0+tg4TRFmqN1OKyiZNllUNLynLekayCUg5y4vCm6F3/yxQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=WWYkG/nqy2L/vExUT8QYNNar+MQph88s0DJGbT1z9AM=; b=AINJZ/6SrgbE5lhBQeE+qffnEh qBFni82YmoDMQ/fSdGiMrcWbZGwp6DcCJMv5e83TUhR5t+Soc8b3iocNChxUZ97O4dVoZuIO5omJc wwLffc0c2YbtJ8VSCCVEnbDavmBmEnYqLBT1dYbBuRFwa8aGSfw0QkdWeNlAB22opDtxwTYdLiG7C cGZFqGUktFmONaYDkX2gLQ979bbLsxey+ZeiPeyOUnCBnfTTJ6dHH0WOUyLZipho7i9cn/hztyU54 2VnYX+bYNHFZoA5H0YidAZP+4Cn64X9SwyqKVBZY4+RIUgpL9BnmiZORVQXTFiZ002FkA9fbQsRfo MVs4OU3g==; Received: by zero.zsh.org with local id 1rNGs6-000GDE-F5; Tue, 09 Jan 2024 18:30:42 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f46.google.com ([209.85.218.46]:42019) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rNGrn-000Fvs-Nk; Tue, 09 Jan 2024 18:30:24 +0000 Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a28da6285c1so583740466b.0 for ; Tue, 09 Jan 2024 10:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1704825023; x=1705429823; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WWYkG/nqy2L/vExUT8QYNNar+MQph88s0DJGbT1z9AM=; b=BuRMuMfsIOI/hUanoR09cxdD4P4xcq8J8x6aM4vBph9MWMxH6ddpu+x9wspeAuk0cR HTf57Cie2XpzmNTqOpEe63sL6HlnyWT2Al9caqF4qjaGZ1rwfvUD+LmDMC5asoUdmAWu 3OqfMThVIRvBvOVV4ASgGS85xoDjJtnm3s0P8wEUV0ByqvTQib8pFGE9Lt8lDgSrGH05 eLNqFfboP7jQmnKJV9gmEjcCM3Vaw/xM5EzbJr8Cx45nlOLYRzh58FwxQEgWBTpaMks8 iUuQ6yKnv3dtmD8ExmknYh5TN4suJ2vg+ZrUlRLrB/qE7wmyR+yyxMejRcc4HRVmyvxx 8nfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704825023; x=1705429823; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WWYkG/nqy2L/vExUT8QYNNar+MQph88s0DJGbT1z9AM=; b=nDSSksYq5guNf3ni7kRZgeeALNUl273+vQfHeoeppn1ffgsUuGxeB9IDsK7fPME1Q4 aJTh1PWlfQuguuLOXYLGVEwGWCo7/L5wSQuN80NtG1Mk8IejWrseYjzrwRE5ArfhZLJm OurgjxId4vuG2I2k7bs1UcOha2gEvDiDzj4drANiffu24r8WHfm/U4DKYAZu8ai4+HEW 6Doi5cSCeB1cPQKeSMNmPX44Rzbr7F9sWJXmoe8yKVBIeZWjguMqN875fHnnSS+E9UNh ugNsmWUDAWlGrs79knCcY1pnx9mCSAdqeJJEZ1uRgjlwb5Zi7spUiuWH4xd9rxb87UkE mkEw== X-Gm-Message-State: AOJu0Yy07ZgfbUy3HoUSkXn+dOAMEqBPXMQ+832Cn+51A4hixgC/vIku 0HioFMvQJuqBgGqh0Jtr4DiVRbCsvBJ67+3uJN51XJYIt/BkuviAQMPUZXrqxQ== X-Google-Smtp-Source: AGHT+IHG1og1lUPos669GuC8kI7FljsWeF3+LfpUieuWlC6YjqewqtsSjDFlJ5M8baMb2OKL1YaVsY/Pk3HwIwR07Xg= X-Received: by 2002:a17:907:1b20:b0:a2b:2de2:8dd4 with SMTP id mp32-20020a1709071b2000b00a2b2de28dd4mr1751957ejc.15.1704825022939; Tue, 09 Jan 2024 10:30:22 -0800 (PST) MIME-Version: 1.0 References: <244348347.2089761.1704732731254@mail.virginmedia.com> In-Reply-To: From: Bart Schaefer Date: Tue, 9 Jan 2024 10:30:11 -0800 Message-ID: Subject: Re: [PATCH] Re: Should we be avoiding "zstyle -m" ? To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52475 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Tue, Jan 9, 2024 at 1:17=E2=80=AFAM Mikael Magnusson = wrote: > > I don't understand what the \ does in your context argument for zstyle -m That is in reference to url-quote-magic. The more typical usage would be in completion, e.g., in _sysrc zstyle -m ":completion:${curcontext%:*}:values" cache-policy '*' where the context argument is built up by the chain of calls below _main_complete and actually means something well-defined The \* in the url-quote-magic context is just there so that the part after the last colon is neither empty nor a legal value for a URL scheme. > This makes me suspicious that maybe the code doesn't at all do what > the author expected it to do? It's expected to return false for e.g. zstyle 'zstyle ':url-quote-magic:http*' url-metas '+*?[]^(|)#{}=3D' because that context is more specific than zstyle ':url-quote-magic:*' url-metas '*?[]^(|)~#{}=3D' for which it should return true (and does as you found). The idea is to install the least-specific context whenever the user has not already defined that, so that the user doesn't need to define contexts other than the most specific. So it needs a context that will never match something more specific. The actual lookup, later, always will be in a full context, so is expected to skip the least-specific default when the user has defined something more specific that matches. > I am slightly more confident in my view after the following experiment > (again a new shell): > % zstyle ':url-quote-magic:\\*' url-metas '*?[]^(|)~#{}=3D' > % zstyle -m ':url-quote-magic:\*' url-metas '*' && echo true > true > > So if I've set the url-metas style for the \\* context, the code will > now override whatever my url-metas style was set for in the * context No, it won't ... it would only override when zstyle -m returns false -- the tests in url-quote-magic are all || rather than && This is a different bug in that asserting a style for the '...::\\*' context ends up being equivalent to setting the default url-metas to unset, but given there are no sensible contexts that contain a leading backslash, this would never occur unless someone were deliberately trying to break it. > On a more general note, I think the whole approach is wrong and we > should never set a style if we think it's empty; just use the fallback > value when you look up the style and it was empty later on in the > code, that will never have weird subtleties like this. True, but it considerably muddies the code that actually needs the style values. In url-quote-magic, that also means pushing the defaults for some styles down into helper functions so they potentially end up being mentioned more than once, and it prevents setting up the defaults at autoload time so they don't have to be re-asserted every time the function runs. This could be a bit less messy now by using namespace parameters to hold the defaults, but at the time zstyle was the only explictly-scoped global cache.