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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25670 invoked from network); 12 Sep 2021 17:44:33 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Sep 2021 17:44:33 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1631468673; b=bqg7VwO0hXgIdr0FztNkFtvtRC/pyvGIBJZuLJP45EkZ6QjepJbQh0nWVntE+IaV7k0+JpQ8PB 6SBf14cL3IFPZgo+zyGXKSOKHG/IYCogWwkbTxmBX7yUAYpZz1mg+lahs9juaics6M2Efh4rW2 dD9L2742KZl+aYyLP37b3rDm/c+4B+nUxaUjjNc5SwotOOdl0LWGCzRPJgvm6ONsl4n8dXdl5N 4QdTp9u2s27D+BRzkMD6jUNmukJKDTvOrForvCjn0le5Qw4g9r+EaKma3DZ8yoY255aoQO6/F7 u3blMwllcAKyY0jgauVEMDRSQETn2JoYfpD9RIyS2ZwFfQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f174.google.com) smtp.remote-ip=209.85.219.174; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 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=1631468673; bh=8PrJ+HooLcPF/JRtxtGTB1IBxdXAzXxXlWfRMV2tYfg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=DQ6TyNZTcfWqicOKQg1m5u0JOgvzde4miTTY9V2mqKm5+bvrEl9ozIWf75Q+TnQd3tcB5o6uqy w+A/s0FG5ciIZLuyCemQdM6YS1gbAbdHGTf8rM9b1zRCjeJT34xqGAJWDgkRJCeqqCfM0Z8i9D 6nFegBOi1ccy0iTWIl11IiZm01IxjVGYhL6FDxfN8cc2ZUMLVj5/kPr9qgJwN2ftJZyqYI8ngQ 1TC7dRKMUZuc2z9La0s/q5lBXFs9nMhDFYfALnY9YDt1zd1oozaabaIrvepLTJQQ07O0BFGA1y FIYFe4FZQFi30OsRylmV+1rv3glqhEEN1EXtNDqlo9j18Q==; 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-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=/fVrIUWDy3kZp0g2PQJR+haZ6rndP2hRE2IrVuYePd8=; b=Y2tt82ee+HC8m0mgQLVZFlaSCI mLBFVdg2Nb6N462q8Fthv6i475YbwCS6usVRQ+Rad8eFtzhiOsKewuDFTwE6D9QVEHo8RRJV3QCgb g1D1nGWT0Exmy9s53rJuY2iKtv0UEDGVIh1HuDvwTaLTeVh0Tk0UUvumPr/xNNn0YNDM+C3sWzrnL 6eCUO6FcdVOBzVWMuuVgvBWuG3QdjirfGYsIasI+aqmK0V0gTR5z0seeXRqyUuaoWGMXqOpWGnsdm NfVCQiuM2fgdes2AJsaSYsTNgLdHTZPqedincWfMhPxjH6Svnq4uJGOSkRcYwj+dAzAyUa1vYnAyT Q+cdc1lA==; Received: from authenticated user by zero.zsh.org with local id 1mPTWp-0009DD-V8; Sun, 12 Sep 2021 17:44:31 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f174.google.com) smtp.remote-ip=209.85.219.174; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-yb1-f174.google.com ([209.85.219.174]:44691) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mPTWH-0008uK-OX; Sun, 12 Sep 2021 17:43:59 +0000 Received: by mail-yb1-f174.google.com with SMTP id s11so15422476yba.11 for ; Sun, 12 Sep 2021 10:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=/fVrIUWDy3kZp0g2PQJR+haZ6rndP2hRE2IrVuYePd8=; b=yRdLWeDHXkQVrXT5J1i4A2A0Vli+grSpPUyBiyZirMuE/VwX+yk4aVjDDutidcYJmS T5S8PMs+lQcq/3V4Rs5fiyaayEi0nrEyc/4LdNYKJDwV9zT6/RV+2hBaBEho2GeiuRIM AgLJEZSjwQyDDsIfkT3tcUdIPxRnkKG9CohTe/TxzrMgVsz3HTzMjIWbSyaDlmQOt5hI ZHR1UuUc73s1Svh1WrIhqoQklcAhQFPjLjZv+wwI3AnhXsKvYctaCv0JMLBN3Em2wwjw WIYle2R7g9cujf9PSkz/u1m8WWQLqgFCopt0Kz1D/ct5gKg5ozKBj8k19qug/n7wQq83 yiiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=/fVrIUWDy3kZp0g2PQJR+haZ6rndP2hRE2IrVuYePd8=; b=kMyMF4qmNXdRsUMrO+BNdpfl5l9AKe6QFbolWPzIkAu9R1f6FhqQjJkM6RV5NRCgAh oT+sr3ati8x56651gPD+AKUK8lKwGGlqU4UnnitvkBS5RKeUZLTlNh7UgicSII9nVQ5H yISSJoFyLVblfJE7KeX0VP5Wjbc0SdP80OxobXlktBSUaRRnBbUMCmGiXgfrV7YrLb0/ t9M+lh9p5lgbEfieoNy/CHh4jn1oLKPbLUe+iV2xX6FKuG5OvxrvkbWsmCFIbuHaDC3W mMdZHmXbT4bQTMBqPEvNdTjJUalVuTo7Cx+TAxM3zg72watIPlViJqvroXQUwa6JKx9V pyEg== X-Gm-Message-State: AOAM5322Y1uVq1aac5DX1TmMolloaZc5Y3/ItefHnThm/AoETTDMnrh6 f2ukwMHP4yXfpzTncU4/NHmH/4tE7/qcDQR+QeBmtQQyAED5GQ== X-Google-Smtp-Source: ABdhPJzozgLZUY4UDWm95mOEAIWYXaPDM7js4upPtOkEuVojS/SUjrj8Z7WcAzmcnfUD4qGy0IRIlYddkMjc97X0Oks= X-Received: by 2002:a25:7449:: with SMTP id p70mr10403108ybc.89.1631468636081; Sun, 12 Sep 2021 10:43:56 -0700 (PDT) MIME-Version: 1.0 References: <20210912081151.k5cqsw6tdmkj7mi4@chazelas.org> In-Reply-To: <20210912081151.k5cqsw6tdmkj7mi4@chazelas.org> From: Bart Schaefer Date: Sun, 12 Sep 2021 10:43:45 -0700 Message-ID: Subject: Re: Why do we need to quote # in ${(#):-2\#1011010} ? To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49410 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 Sun, Sep 12, 2021 at 1:12 AM Stephane Chazelas wrote: > > $ echo ${:-2#1011010} > 2#1011010 > > That # is fine when not quoted there, so why: > [...] > It seems to discard everything after the expansion within the word: > > $ echo before${(#):-2#1011010}"hey, where did that go?" other args > before other args The short answer is that ${(#):-2#1011010} should give a parse error on the number-to-character conversion, but doesn't. In the first case, without (#), there's no parse so there's no error, which is why it doesn't need the backslash. I suppose paramsubst() should be calling zerr() somewhere near here: 3553 noerrs = one; 3554 if (!quoteerr) { 3555 /* Retain user interrupt error status */ 3556 errflag = oef | (errflag & ERRFLAG_INT); 3557 } 3558 if (haserr || errflag) 3559 return NULL; The other option would be to unmetafy somewhere before calling substevalchar() but since multsub() also sometimes unmetafies, it's not clear when to do so. Or perhaps something upstream is unnecessarily over-metafying when the # is not escaped? More details (just notes as I step through with gdb): FAILING CASE We arrive in paramsubst() with "\205\217\210\204\212:\233\062\204\061\060\061\061\060\061\060\220\236hey, where did that go?\236" val becomes "2\204\061\060\061\061\060\061\060" at line 2948 multsub() does nothing, so substevalchar() returns NUL at 3550 and haserr = 1 so paramsubst() returns NULL as does stringsubst(), but without an errflag and prefork() bails out at line 146, which truncates the word. WITHOUT (#) "\205\217:\233\062\204\061\060\061\061\060\061\060\220\236hey, where did that go?\236" Everything is the same as the failing case except that substevalchar() is never called, so there's no error, and the result is simply unmetafied and returned. WITH BACKSLASH / WORKING "\205\217\210\204\212:\233\062\237#1011010\220\236hey, where did that go?\236" val becomes "2\237#1011010" multsub() unmetafies it to "2#1011010" and substevalchar() returns "Z"