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 7438 invoked from network); 22 Apr 2020 17:12:56 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with UTF8ESMTPZ; 22 Apr 2020 17:12:56 -0000 Received: (qmail 5342 invoked by alias); 22 Apr 2020 17:12:48 -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: 24802 Received: (qmail 11081 invoked by uid 1010); 22 Apr 2020 17:12:48 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f50.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.50):SA:0(-2.0/5.0):. Processed in 1.046274 secs); 22 Apr 2020 17:12:48 -0000 X-Envelope-From: pierpaolog@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.50 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:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XgfMP+znQnF0+ReIr8ZpgnrAkd84S51i17ERU7+f7CY=; b=UQ3pkDZbb+sbD9lc5vv+vzxyM88WofEsMgH+gA9VWiEiNfCeWB8zxOLHcFle4Jd119 vPF+uf7Me+vFEU7HigEFTFsvsjlGTSCF0Bw+qVjhBnM8Vr/b4Yl0knteMrF9jtSeIIQm zsqWa5t5kBjzXAv/PhwakyiYldzO2Hx5VWmJwoAuybh91Ot8kItMrHL4sAMKGCNpJIkr b6EIWGruAd8lvWLEEo+cZHC0jNpwE5TqKQN99mamhq3iLA62/jezz8v+20B359JfTKXm vMFY3TDs5I/RolxpbAptYRKAbU6Y5rVvV7XANpgJS5v7pzrk53VL88Rh4Lu3CTacEv3n FM4g== X-Gm-Message-State: AGi0PubGIn4Z3YTm5kuIiq50Y5/HyF7gZ8luZAlPvZVhZ3USGqyxgCRZ 1D7SsOWIBkGI8lEXmcljWuHP4Hf26MaLpjSiPXw= X-Google-Smtp-Source: APiQypK6bG6BTCLRMpYoIZU/D0ZE2n5qULW3C/J6gF5Kh29tzzqYtauW9AgS39Z0V6UO2aJ/+LzSWqw6zGAf/t89/tY= X-Received: by 2002:a02:3341:: with SMTP id k1mr27019655jak.74.1587575534341; Wed, 22 Apr 2020 10:12:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Pier Paolo Grassi Date: Wed, 22 Apr 2020 19:11:38 +0200 Message-ID: Subject: Re: field splitting To: Mikael Magnusson Cc: Zsh-Users List Content-Type: multipart/alternative; boundary="000000000000c7568c05a3e43b14" --000000000000c7568c05a3e43b14 Content-Type: text/plain; charset="UTF-8" doesn't seem to work line="abcd" echo -n ${${(As: :)line}[1]} a Pier Paolo Grassi linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217 founder: https://www.meetup.com/it-IT/Machine-Learning-TO Il giorno mer 22 apr 2020 alle ore 18:47 Mikael Magnusson ha scritto: > 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 > --000000000000c7568c05a3e43b14--