From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 4624 invoked from network); 22 Apr 2020 16:48:18 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with UTF8ESMTPZ; 22 Apr 2020 16:48:18 -0000 Received: (qmail 7492 invoked by alias); 22 Apr 2020 16:48:11 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24801 Received: (qmail 1709 invoked by uid 1010); 22 Apr 2020 16:48:11 -0000 X-Qmail-Scanner-Diagnostics: from mail-il1-f179.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25786. spamassassin: 3.4.4. Clear:RC:0(209.85.166.179):SA:0(-2.0/5.0):. Processed in 0.798562 secs); 22 Apr 2020 16:48:11 -0000 X-Envelope-From: mikachu@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.166.179 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=z+zX2sihmbXB14BJC+7H9WFjWBEfSFVbhTao1Q8KKMs=; b=lt8f65Z3Pc/7uqIQbD17IasP2RmEQB2mP/tl++pN8m9Jmp5pYasVUOnGZ5Q6soXr4A Zs9Q7WJCGRksgvRaRYTaFRV8fUoR94QxEi60a4Ed481GX/GL+B7ClYCDEOOAOG+53CRc +RYLEypQ75DkJVORoT6rs1h0GSFBFWDnZYhKI570jXWALAcTbhkZ2q5iBhtkhCT5UkPd /tdfIloCiZP0mrxNM/qcYbLWQJgzg/gS61L0AD9YDFOQ2dqHK5GQTmwRAWGLtrnHunjJ jwa8M+FuiCpaECWtrKosEzsmm2rC/TQACt1iJf5Vm1U1kkbvlltOY0p8PPBNoFsfWWAl HVUg== X-Gm-Message-State: AGi0PuZ1ALlyH4Pr+zYvU6PYYlX7nvNJsdRZVeUE/KRFTeGv6N5OtInT ZCedWla2wP3QkPGPNAQ9e/wG/tm5UHxnmivJQA1WrQ== X-Google-Smtp-Source: APiQypL5/naYegKi7wCEF6zu4N1zvtBhac62MvXtJHs0okvo9zuftniR97T5gxPXC3vw2h9QTDuqbgKJG3Z3a9Ulkiw= X-Received: by 2002:a92:2904:: with SMTP id l4mr15600268ilg.159.1587574058119; Wed, 22 Apr 2020 09:47:38 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Mikael Magnusson Date: Wed, 22 Apr 2020 18:47:37 +0200 Message-ID: Subject: Re: field splitting To: Pier Paolo Grassi Cc: Zsh-Users List Content-Type: text/plain; charset="UTF-8" On 4/22/20, Pier Paolo Grassi wrote: > I am trying to use field splitting to get the first word of a line. I am > using: > > echo -n ${${(s: :)line}[1]} > when input contains spaces I get the first word as needed, eg: > line is: /usr/bin/python - /usr/bin/python /usr/local/bin/terminator > what is printed: /usr/bin/python > > when input does not contains spaces, however, all I get is the first > character of the line, eg: > line is: /usr/bin/zsh > what is printed: / > > I have trid forcing the array expansion in various ways: > ${${(@s: :)line}[1]} > ${${(s: :)line[@]}[1]} > ${"${(s: :)line[@]}"[1]} > > but I couldn't get the desidered behaviour > what am I missing? echo -n ${${(As: :)line}[1]} -- Mikael Magnusson