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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13875 invoked from network); 4 Nov 2023 08:49:55 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 4 Nov 2023 08:49:55 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1699087796; b=pMGPDpXmZ6pABw407uYwpeXZm/MM+0qo1k8flkhj3bcNNLYIiIIWcyMhcSlCIcF5ql48bCF+TC kRcjMrh1ia3u1BM/2bRPXT/9ACWIjkJxLa6oEkrsDPmO+LGawLCf8xVXiNaFNX6+SuVpSXVqHg pynE0aQNlOpfTVHFovYu144fc30m6u+XHm6GB79o011VCh04SV4YoDiSqJOfPX7viLjwcbo74/ xvqTFY216SomS6z2TZufanjdT/+/DsqiL7mgh7GZL+m3lyiwvTu9pietPUcZSXAs2a3C2Y8Oje i2mNhPhZdMooMH1NLEfTJl3Y5Lk6olq0oFiGrovWK0DviQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f171.google.com) smtp.remote-ip=209.85.208.171; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1699087796; bh=Izirvc064D4MqfuTyxXMqkG0fq8am0vC/S3HxW0zdvA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=Ab4ECS0ZKBqY/XVJEVNNX73Hn1/BU27ToIIJd0zef7xFEOCxl+O4yeKPMjHco6xGCAnY3vmtiY 3jChHgFeL9xX9hdiiNp6QQYdDal3hKsxaofq/BRM3StxtZacKTrBO+zTqJuoTwCK866MTTlpEJ 5mDGxud5CTNp37UWYh3/8ts/LRThajv5kOArMURc+FXzWhnHHu2Ko/Gor337yd8nRgriACJYh+ 2dPvGWqaeWk+w/W4uEzcx7FWTTCp9DDJI+wMFxXMA2iy5AO2pkmOhCCiHbAgzLC6gIZWYiCpjC pQK9wKrTAQvygNzCbAkHB0NazCYebfEAfkYsyfex4z178w==; 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:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=nFnorqHurq0Zlpo+d2rZSfOZ2sgD+vW6dvcJTLx0/8I=; b=idIlA3sfKQ03Iu0zoij4oXcNbg UshfmqJADS8mrCIH2BOObDSt7Cww9fWEBH2BYuAKRhjoKA8e6F6GZ1PYkco47EUzjzHoOcp+2gaKm 3RvrMV+vWB1A4EbZoYpIjg0X19by1WhP0t+3+/qYiAoVGDYmx+Ir5CBgGWe0q7+KB8qTwAkf7Q6Jd cFDKReG241V/3Vxr+yEfQUr6Cbe8pVfTpa8wABpJQUm6+EfMsNn8gRMofCG15qoIUb1iuQumIR4hm nGNbGd3/pwzsSzLFPD5tLFuICocsZjVj3Tg2OoKPbWLs6mfYSE0J6D8VFWT6DBbfo+knQtRtBywVC G4LLp8Fg==; Received: by zero.zsh.org with local id 1qzCLr-000Hh9-7L; Sat, 04 Nov 2023 08:49:55 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f171.google.com) smtp.remote-ip=209.85.208.171; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f171.google.com ([209.85.208.171]:42316) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qzCKe-000H1y-7c; Sat, 04 Nov 2023 08:48:41 +0000 Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2c6cb4a79deso30652291fa.1 for ; Sat, 04 Nov 2023 01:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699087719; x=1699692519; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nFnorqHurq0Zlpo+d2rZSfOZ2sgD+vW6dvcJTLx0/8I=; b=IZDlhsujBzNoPF8kp19PeMmLw/ocZDnTofKGja8GbYLvuJ7V77fItgC7qo8OIm/Gj8 U0wu79lwOjnOcwjLo1Jm4H9mmxPO8jOGsNaLVZ3Hb66EMOSJxozIOr6bNqFpFuRfDDEV PPk92rn5kKVW3YY8C+1EPRNd3T5w6zBecANqjxyZHVMqx4jZvlKNr0NPYNPDMz1xF4ri oTYZZn/Objz8dAfyalK91Fqxg4V4IyfsGlPSSk5qgtbdsi4vqQRPbSoyRxLRzXqjRFpl S7eFhE3lYkaAZ6+YIqz6ScN+WgduofL+rw4+yeeapi0dNPXLPJN12w5/UFFwO3AgiShT mOXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699087719; x=1699692519; h=content-transfer-encoding:cc: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=nFnorqHurq0Zlpo+d2rZSfOZ2sgD+vW6dvcJTLx0/8I=; b=RRYyR5/ZIa9cvZ+JZfgnpC3tLdN+GnP44G0Zsd4Pel6dcfinn2c9FDrn9Yhe6epv5l 3dMprU8QowABblDpMd6LkQMZIIxhbpy/Wot/0LIWa4vHj0KLQelfisf4pmpfYKJnYXXr SfYKCMAOYTvXNRvta/JZOtvDezzM4Kzej8r0AAwisvWKSXouTWoBHtTLvur2i4IsmiH5 abYsLeQ7TVRmwB7hWw8bKoP1OnbxaVmU8n27Qe9PyeCo7sKkrL8nunPY3GAEd1mw8Um8 6YYrrvZeZkSojGcN7lo7b9Ze7ll3F3Cf6kuVGVQUerU4raDribInlRFrrubUH0nsUWE9 k/Tw== X-Gm-Message-State: AOJu0Yy/TjyEQB+9rVZ9V8OFcD5zP6KVH/7X4KyJHZrlm3SUzH6gpRua 8vsNyqYYxN9i+cUoHITl/f0fxXJlzFncGK8gl1g= X-Google-Smtp-Source: AGHT+IFeHCaz9c1VX/VNV5et0VfrFhBs2MMo/cFWmq+u4wbDcS7zDl/3KEdBohsCijw88ZS1/4Wft4JJNLbZtPqf6LU= X-Received: by 2002:a2e:b889:0:b0:2c6:efed:e494 with SMTP id r9-20020a2eb889000000b002c6efede494mr1947661ljp.19.1699087718978; Sat, 04 Nov 2023 01:48:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Sat, 4 Nov 2023 09:48:28 +0100 Message-ID: Subject: Re: subscript not working as "I" expected it would To: linuxtechguy@gmail.com Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29319 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: [cc:zsh-users] On Sat, Nov 4, 2023 at 9:47=E2=80=AFAM Roman Perepelitsa wrote: > > On Sat, Nov 4, 2023 at 8:09=E2=80=AFAM Jim wro= te: > > > > After beating my head for a while, it dawned on me to try quoting > > print -- ${"$(<.git/${(s.: .)$(<.git/HEAD)[2]})"[1,9]} > > which worked, returning the first 9 characters of the hash. > > > > Could someone explain why the quotes are needed here so hopefully > > the next time I will understand. I swear zsh quoting will drive me nuts= . > > $(list) expands to an array. ${$(list)[N]} gives the Nth element of the a= rray. > > % print -r -- ${$(print foo bar)[1]} > foo > % print -r -- ${$(print foo bar)[2]} > bar > > $(list) can be an array with just one element but it's still an array. > This is the case in your code snippet. > > "$(list)" on the other hand is a scalar. ${"$(list)"[N]} gives the Nth > character. > > % print -r -- ${"$(print foo bar)"[1]} > f > % print -r -- ${"$(print foo bar)"[2]} > o > > Roman.