From: Marc Chantreux <eiro@phear.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zzapper <zsh@rayninfo.co.uk>, Zsh Users <zsh-users@zsh.org>
Subject: Re: (prefix case terminators?) Re: alias with a parameter
Date: Fri, 16 Apr 2021 08:46:55 +0200 [thread overview]
Message-ID: <YHky3+HIR0eRsLvj@prometheus.u-strasbg.fr> (raw)
In-Reply-To: <CAH+w=7bFEnvAYAkP6=rUdUoZzcySBHN7iinPWc9OJ7seOsciHw@mail.gmail.com>
hello,
> > i would have written ${1-} so -u can be used.
> I'm not following that at all: -u where?
oopps. sorry i was too fast writting this. i meant nounset option.
i want my shell to yell at me as soon as i do something wrong so
my ~/.zshenv starts with
setopt warncreateglobal nounset pipefail
> > also: i really think that using terminators as "continuation"
> > ease the code reading
> Entirely my opinion, but I find your example much MORE difficult to read.
Thanks for the feedback! As always, i think everyone comes with cultural
biases when it comes to coding style. when i read
case "$var" in
(a*) write ;;
(b*) something ;;
(c*) cool ;;
esac
i would like to see/write
# in raku
given $var {
when /a*/ { write }
when /b*/ { something }
when /c*/ { cool }
}
# in rc
switch ($var) {
case a* ; write
case b* ; something
case c* ; cool
}
and i used to actually read/write
# zsh
case "$var" {
(a*) write
;;
(b*) something
;;
(c*) cool
;;
}
because i though for many years that alternative syntax will replace the
old one the way zshcompsys replaced zshcompctl. but:
* it will never happen and i have to fall back with the classic syntax
whenever i contribute to existing codebases.
* i started replace zsh by dash or rc in my scripts whenever the
awesomeness of zsh doesn't help a lot (which means "lot of them")
so now i try to stick to POSIX syntax whenever it's easy to do it but i
try to adapt the coding style so the code keep staying attractive to me.
> > * it's easier to spot a different terminator than ;;
> For that, I'd put the terminator on a line by itself, which I would
> also do if the case branch was more than one line or if the case
> pattern was quite long, but with short patterns and the terminators
> all ;; it seems unnecessary.
indeed. what i just did is to remove a "useless new line".
...
some code
there
;;
(newcase)
and
...
some code
there
;; (newcase)
both to me and the interpreter and the second one looks much more
natural to me. i'm not trying to convince anyone. i was really please to
read your feedback so i try to share my opinion on it.
regards
marc
next prev parent reply other threads:[~2021-04-16 6:47 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-05 22:55 dukeofpurl
2021-04-06 0:16 ` lb
2021-04-06 3:40 ` Duke Normandin
2021-04-06 14:42 ` Greg Klanderman
2021-04-06 2:47 ` Grant Taylor
2021-04-07 7:05 ` Stephane Chazelas
2021-04-07 12:48 ` lb
2021-04-07 12:58 ` Peter Stephenson
2021-04-08 1:06 ` Grant Taylor
2021-04-08 1:25 ` Daniel Shahaf
2021-04-09 2:55 ` Grant Taylor
2021-04-09 22:49 ` Daniel Shahaf
2021-04-10 7:32 ` david rayner
2021-04-10 10:38 ` Marc Chantreux
2021-04-14 11:10 ` zzapper
2021-04-15 18:19 ` Bart Schaefer
2021-04-15 19:56 ` (prefix case terminators?) " Marc Chantreux
2021-04-15 23:52 ` Bart Schaefer
2021-04-16 6:46 ` Marc Chantreux [this message]
2021-04-15 20:30 ` Daniel Shahaf
2021-04-16 7:34 ` zapper
2021-04-16 10:12 ` Stephane Chazelas
2021-04-10 16:30 ` Grant Taylor
2021-04-10 16:34 ` Grant Taylor
2021-04-13 11:22 ` Daniel Shahaf
2021-04-07 14:43 ` Daniel Shahaf
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=YHky3+HIR0eRsLvj@prometheus.u-strasbg.fr \
--to=eiro@phear.org \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
--cc=zsh@rayninfo.co.uk \
/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).