From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13656 invoked by alias); 17 Oct 2016 04:06:56 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39661 Received: (qmail 26319 invoked from network); 17 Oct 2016 04:06:56 -0000 X-Qmail-Scanner-Diagnostics: from mail-qk0-f169.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.220.169):SA:0(0.8/5.0):. Processed in 0.348237 secs); 17 Oct 2016 04:06:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=DATE_IN_PAST_12_24, FREEMAIL_FROM,SPF_PASS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.220.169 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=DgNPNNt0DEV4FHGo9dQBwrjh16M6Gt9DvqE/xXZLtBU=; b=dZZAB44bKhbjy0gSfi3y2JjAKWCAhe/rIM4Mpla+z8ALLQsMmDypa4KD/VJVlL4AoG wVEN3o1Xtza7CvyH0uD4aXRrBRO4+oOdNIlZhSmVD4KjFQ8dJ8pkDEBZKqVBHJ7rQYS4 3op6dHTLZAayJXa/IddM6DA4msq4qnyzMjunJumvDBFKHvotC+NMISMhxEmsbRmQnUkA FAR5uSs13S6u/vja3oUWbFU0Ag04n37MDlo52K97B+YPWVYGnBVR2qxM9MUkBMazZMYt 4uBVOFl/9Wyb6gu38U07QR8fnj3VLYxz/yUeBo2kscKFUvfCv4dGW7Dwr6Dv5QpWJkBO B8Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=DgNPNNt0DEV4FHGo9dQBwrjh16M6Gt9DvqE/xXZLtBU=; b=I7EmFvsoKTFa2UDIatorUGLwdyvoGuOPMUS2mDUNbKaa5HZ1RX2fthBqCBZxL/oopj OPz5E6VHNJekimhv81VWAoVkyHWO3QM+dXN+kWStbPXaGraCqpsjJoOMEE5x8Q1jcEHf zhKFtmpfONa7UAtm+nKJWhKBrT2bm1emZn63sk3Te20GQfTpMyvQQPIUdG6fUHTWYOxQ +ax8+zLaQGVwyIiopfIGHwbaeZY69H9qgDHEaUNaHKGEA9nawDSiGMwSVw+0KvvEWcXe WMjSJDNHisv60EF7R8l+u0LToV22OLQm51AzAE0dkXHwRtwHHdKqK8qcqm2K4DWDt+J5 h76Q== X-Gm-Message-State: AA6/9RkYJXzmVNpnsPDkTg3cfcjqUKdo5Fx74GjGxm8NNQGqiZIaS7ED53s7a2zPP8Q5f0SbLnL0yVbNkdsqZg== X-Received: by 10.55.140.199 with SMTP id o190mr9380763qkd.299.1476609328318; Sun, 16 Oct 2016 02:15:28 -0700 (PDT) MIME-Version: 1.0 From: Sebastian Gniazdowski Date: Sun, 16 Oct 2016 11:15:08 +0200 Message-ID: Subject: $match size limit, suspicious (#B) behavior To: Zsh hackers list Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello, turns out $match has a size limit of 9: % a=3D'abcdefghijk'; [[ "$a" =3D (#b)(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k) ]] && echo "match[9]: $match[9], match[10]: $match[10]" match[9]: i, match[10]: Which can be to some extent worked around with (#B): % a=3D'abcdefghijk'; [[ "$a" =3D (#b)(a)(b)(c)(d)(#B)(e)(#b)(f)(g)(h)(i)(j)(k) ]] && echo "match[9]: $match[9], match[10]: $match[10]" match[9]: j, match[10]: Now the difficult part =E2=80=93 but just count the parentheses before and after (#B) =E2=80=93 my input is: mybuf=3D'if [[ "$mybuf" =3D (#b)(\$([[:alpha:]_][[:alnum:]_]#|[[:digit:]]##)(\[[^[:space:]]#\])(#c0,1))= (*) ]]; then : fi' Now code that matches either $var, ${var}, \$: while [[ "$mybuf" =3D (#b)([^\$\\]#)((#B)(\$([[:alpha:]_][[:alnum:]_]#|[[:digit:]]##)(\[[^[:space= :]]#\])(#c0,1))|(\$[{](\([a-zA-Z0@%#]##\))(#c0,1)([[:alpha:]_][[:alnum:]_]#= |[[:digit:]]##)(\[[^[:space:]]#\])(#c0,1)[}])|([\\][\'\"\$]))(#b)(*) ]]; do echo "Got: ${match[2]}" echo "Match 1: ${match[1]}" echo "Match 2: ${match[2]}" echo "Match 3: ${match[3]}" echo "Match 4: ${match[4]}" echo "Match 5: ${match[5]}" echo "Match 6: ${match[6]}" echo "Match 7: ${match[7]}" echo "Match 8: ${match[8]}" echo "Match 9: ${match[9]}" mybuf=3D"${match[8]}" done Output is: Got: $mybuf Match 1: if [[ " Match 2: $mybuf Match 3: Match 4: Match 5: Match 6: Match 7: Match 8: " =3D (#b)(\$([[:alpha:]_][[:alnum:]_]#|[[:digit:]]##)(\[[^[:space= :]]#\])(#c0,1))(*) ]]; then : fi Match 9: Got: \$ Match 1: " =3D (#b)( Match 2: \$ Match 3: Match 4: Match 5: Match 6: Match 7: \$ Match 8: ([[:alpha:]_][[:alnum:]_]#|[[:digit:]]##)(\[[^[:space:]]#\])(#c0,1= ))(*) ]]; then : fi Match 9: "Match 8: .." is: "the rest", i.e. (*). "Match 1: .." is: "before". "Match 2: .." is the $var, ${var} or \$. The problem: (#B) should have disabled all parentheses from where it is placed, and "Match 8: ..." should be at "Match 3: ..". Also, "Match 7: .." has the same value as "Match 2: ..", which seems to be a problem. Best regards, Sebastian Gniazdowski