From: Julian Prein <druckdev@protonmail.com>
To: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: (z) word splitting on one word
Date: Thu, 22 Sep 2022 13:44:06 +0000 [thread overview]
Message-ID: <fi13aLA23DIaMSQDwFOC7p-W1_XNSmw3Xhh_Fkkq-NUZyxeAVYl5HMY1V3w-Ededqf8f9icKw-9pugvbzme5bmIa9_FB8iNXSU7YZlnoagc=@protonmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 576 bytes --]
Hi!
I am trying to get the last word of LBUFFER.
What I did previously was:
${${(z)LBUFFER}[-1]}
This worked flawlessly until I noticed today that it misbehaves if LBUFFER
contains only one word. In this case it seems like `[-1]` acts on a scalar, as
it expands to the last character instead of LBUFFER as I would expect.
Is this expected behaviour?
I now work around it by prepending LBUFFER with a dummy word so that it always
has at least two words (I know that it is not empty). But this feels very hacky.
Do you know of a better way?
Julian
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
next reply other threads:[~2022-09-22 13:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-22 13:44 Julian Prein [this message]
2022-09-22 15:16 ` Mikael Magnusson
2022-09-24 0:38 ` Julian Prein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='fi13aLA23DIaMSQDwFOC7p-W1_XNSmw3Xhh_Fkkq-NUZyxeAVYl5HMY1V3w-Ededqf8f9icKw-9pugvbzme5bmIa9_FB8iNXSU7YZlnoagc=@protonmail.com' \
--to=druckdev@protonmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).