From: Bart Schaefer <schaefer@brasslantern.com>
To: zzapper <zsh@rayninfo.co.uk>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: alias with a parameter
Date: Thu, 15 Apr 2021 11:19:16 -0700 [thread overview]
Message-ID: <CAH+w=7YzFFNXYpSaWL9hBsZ4km7GvhW8mWT8HQTGkDjfcsO5bA@mail.gmail.com> (raw)
In-Reply-To: <6717f359-f340-a436-c2dd-1b9ae19d345a@rayninfo.co.uk>
On Wed, Apr 14, 2021 at 4:10 AM zzapper <zsh@rayninfo.co.uk> wrote:
>
> Am using a case statement as a ***visually elegant way*** of excluding a
> potentially changing list of Global Aliases from being automatically
> expanded
Sorry, you're using this ... where? ... to achieve that?
> if [ $# -gt 0 ] ; then
> case $1 in
> [A-Z] | V<-> | G* ) ;;
> *) echo "Yes expand"
> ;;
> esac
> fi
It's generally preferable to use [[ ... ]] instead of [ ... ] because
"[" is just another name for "test" and "]" is just one of its
arguments, whereas "[[" and "]]" are syntax tokens with parsing rules
for what appears between them. However, since you're comparing
numbers, you could use (( $# > 0 )) here.
However you really don't need that test at all:
case "$1" in
("") false;;
([A-Z]|V<->|G*);;
(*) echo "Yes expand";;
esac
You probably don't even need the first "false'' case, I threw it in
just to keep the same $? as your original "if".
case "$1" in
(|[A-Z]|V<->|G*);;
(*) echo "Yes expand";;
esac
next prev parent reply other threads:[~2021-04-15 18:20 UTC|newest]
Thread overview: 27+ 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 [this message]
2021-04-15 19:56 ` (prefix case terminators?) " Marc Chantreux
2021-04-15 23:52 ` Bart Schaefer
2021-04-16 6:46 ` Marc Chantreux
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
2021-04-07 14:54 Duke Normandin
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='CAH+w=7YzFFNXYpSaWL9hBsZ4km7GvhW8mWT8HQTGkDjfcsO5bA@mail.gmail.com' \
--to=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).