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 28462 invoked from network); 3 Feb 2021 15:51:59 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Feb 2021 15:51:59 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1612367519; b=FGDqxl2mAMH8jUQZcLkGot8HTNTf2dIUUhWBNVrGuJzJpaynnqNtUsaau9cKUN/YSgee62kHIR 5VB1CaVGuwmxobAqBx91kdjg2qUM8gufAUrRTzqSapxtZc4jkvi/cESxdL6QZ3K64uOUwyBhKE bcR0MuXL23uUsQb/NTc2eZi4OQWWh2PdWwvuTomMAIJIFdal5fUsPUl+PgkWnqeqlhqtr1PEa3 ZIRN4YaQxkrHQs+YKbnVUfuezg8yyzjOLL7/VBG0uZOyoUEoSCkedODPI6CIRBuKVwRQ6lswko DLpuy3aPxGy8JGwQQu8KT+kUEkSEVwPq+sl7572twT4m0Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (so254-31.mailgun.net) smtp.remote-ip=198.61.254.31; dkim=pass header.d=klanderman.net header.s=mg header.a=rsa-sha256; dmarc=none header.from=klanderman.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1612367519; bh=9tldyecRZgSLu8dDeydiB4zVPtUuh5Av1PIrRQYYl9A=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Reply-To:Subject:To:From:Date:Message-ID: Content-Transfer-Encoding:Content-Type:MIME-Version:DKIM-Signature: DKIM-Signature; b=hcxC9+vyGJFejJceAj2L2dr9h809dYpi/OZVKmU15otA5/azxGzll3MT+iyTk4hzk53B92Azz0 sGE/ybcSnDlj+jokJLto1HXIv5vJiumTN+cDkNdtxIBzE7YVnX4/Lzh5PmaHHUKdGm7/YvfmoK 8ycqYN6HWIAwg6rhQSRvNoI3D/yWm5Lb9a3tCXld4vWzfwdKBnVu+RIMNWQg16p431Jr9LOt4U ghulxaovF1cP9oe2xTUgkG374LY3Z81An0i1yYxOdXVJc1wWxJZ4OJ44S0aBcrf9FMEd61e7BY qQXFhxs/o+vSvf8f3mSLGhrzLsd2PRBO5LH+JsqW81j9mQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Reply-To:Subject:To:From:Date: Message-ID:Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=9tldyecRZgSLu8dDeydiB4zVPtUuh5Av1PIrRQYYl9A=; b=RNXIeHmvNaMtglDUfzJ//gnwtJ JmHs5/lqn4Kpl3qasXjIjvnJHW+dzxNa2xKcLSqs8if0XYd/0uvAwkc1IFXKTeDVk1o79N36icTFn IoAmcs/Qf1KjlqqhQle8xGJAnSEh13wGADo1pkpqnNAus0PGaic9YIagJrZ2PUifp3ySziEMCpyF9 XhzztM0bwZXdAtIIxQ8jR7K/LHuiCPWIeoDEZUZPXSkXOlunGy0160cWb64nSDGQP81/TskPSnaAM Ps6oWeyE2cB39X8JUk2mW9R6NfcyfXD/+3/WwqS0XJa0UdvX0HP4UCqr1+aUMBax1PlskcchqJpCi CcEzQ2Mg==; Received: from authenticated user by zero.zsh.org with local id 1l7KRi-0000Vo-Ja; Wed, 03 Feb 2021 15:51:58 +0000 Authentication-Results: zsh.org; iprev=pass (so254-31.mailgun.net) smtp.remote-ip=198.61.254.31; dkim=pass header.d=klanderman.net header.s=mg header.a=rsa-sha256; dmarc=none header.from=klanderman.net; arc=none Received: from so254-31.mailgun.net ([198.61.254.31]:23850) by zero.zsh.org with utf8esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1l7KRR-0000Ml-Pq; Wed, 03 Feb 2021 15:51:45 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=klanderman.net; q=dns/txt; s=mg; t=1612367503; h=Reply-To: Subject: To: From: Date: Message-ID: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=9tldyecRZgSLu8dDeydiB4zVPtUuh5Av1PIrRQYYl9A=; b=Ak4ne11Yu/dMUuz68l6JzDYBbCX+hxN7PgQpDzj6Ts4pPwSYI5FZ0Sb0QsAAw5CQjt9J9Gc/ Dytg1libQ6Cd/u5X2rel71b3LBk959GERjyaT7D+5mdUQF5Mra5q7TJmJlot6YW8DBeB1lEQ o+TlWa1TtihTefWTPqr8g+tKLdI= X-Mailgun-Sending-Ip: 198.61.254.31 X-Mailgun-Sid: WyIwZjNkNyIsICJ6c2gtd29ya2Vyc0B6c2gub3JnIiwgIjk3ZGJkOCJd Received: from smtp2.klanderman.net (smtp2.klanderman.net [142.93.10.110]) by smtp-out-n04.prod.us-east-1.postgun.com with SMTP id 601ac68959782fb5161139ac (version=TLS1.3, cipher=TLS_AES_128_GCM_SHA256); Wed, 03 Feb 2021 15:51:37 GMT Received: from lwm.klanderman.net (pool-72-93-77-73.bstnma.fios.verizon.net [72.93.77.73]) by smtp2.klanderman.net (Postfix) with ESMTPSA id AD74A415D5; Wed, 3 Feb 2021 10:51:37 -0500 (EST) Received: by lwm.klanderman.net (Postfix, from userid 1000) id 6342729E1435; Wed, 3 Feb 2021 10:51:37 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <24602.50825.244206.559048@lwm.klanderman.net> Date: Wed, 3 Feb 2021 10:51:37 -0500 From: Greg Klanderman To: Zsh list Subject: pattern matching, when the pattern is a parameter expansion Reply-To: Greg Klanderman X-Mailer: VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid (x86_64-linux-gnu) X-Seq: 47906 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: Archived-At: Hi, I seem to have found an inconsistency with pattern matching, when the pattern is a parameter expansion: % z=(one two three) in three syntactic forms that accept a pattern, the pattern can be the result of a parameter expansion: % x=two % [[ two == $x ]] && echo yes || echo no yes % echo "${(@)z:#$x}" one three % echo "${z[(i)$x]}" 2 now, when x contains an actual pattern rather than a simple string, it is not matched in the first two cases, but is in the final case: % x='t*' % [[ two == $x ]] && echo yes || echo no no % echo "${(@)z:#$x}" one two three % echo "${z[(i)$x]}" 2 I would have actually expected to match in the first two cases as well; is this behavior of using plain string matching when the pattern is a parameter expected documented? (I know I can get that behavior with the 'e' subscript flag in the final case) There is some explanation of pattern matching in Chapter 12 (Conditional Expressions) which seems relevant but not clear on these cases: | Normal shell expansion is performed on the file, string and pattern | arguments, but the result of each expansion is constrained to be a | single word, similar to the effect of double quotes. .. | Pattern metacharacters are active for the pattern arguments; the | patterns are the same as those used for filename generation, see | Section 14.8 [Filename Generation], page 73, but there is no special | behaviour of ?/? nor initial dots, and no glob qualifiers are allowed. thank you, Greg