zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "s. keeling" <keeling@spots.ab.ca>
Cc: zsh-users <zsh-users@sunsite.dk>
Subject: Re: Porting an alias from bash to zsh fails.
Date: Sat, 23 Oct 2004 21:09:48 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0410232057370.23496@toltec.zanshin.com> (raw)
In-Reply-To: <20041023231442.GA24632@infidel.spots.ab.ca>

On Sat, 23 Oct 2004, s. keeling wrote:

> Hi list.  I'm new to zsh so this could well be pretty simple.  I've been 
> wondering why the following works in bash, but fails miserably in zsh.

It's almost certainly because the default setting of the NO_MATCH option
is reversed in the two shells.  In bash, by default, when a glob doesn't
match anything, the pattern is left unexpanded, but in zsh by default it
generates the "no matches" error.

> What am I missing here?

>    RXVTNEWSFONT='-*-neep alt-medium-*-normal-*-*-100-75-75-c-*-iso8859-1'
> 
>    alias dfn="rxvt +sb -fn $RXVTNEWSFONT -geometry 128x51+69+42 \
>       -e nice /usr/bin/slrn -f /home/keeling/.jnewsrc-dfn \
>       -h news.individual.net"

This one would have worked for you if only you'd put the entire thing in
single quotes instead of double quotes.  There's no reason to expand the
variable at the time the alias is defined; let it be expanded (and thus
not globbed) at the time the alias is _used_.  This has the added benefit
that you can change the value of the variable to change the font used by
the alias, without having to redefine the alias again.

On Sat, 23 Oct 2004, s. keeling wrote:

> Incoming from Lloyd Zusman:
> >    alias dfn="rxvt +sb -fn '$RXVTNEWSFONT' -geometry 128x51+69+42 \
> >       -e nice /usr/bin/slrn -f /home/keeling/.jnewsrc-dfn \
> >       -h news.individual.net"
> > [snip]
> > 
> > This works because the single quotes are treated as normal (non-quoting)
> .....................^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > characters when inside of double quotes; therefore, the RXVTNEWSFONT
> ..^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> That was a surprise to me.  Thanks.  Your excellent explanation has
> solved it for me.  Much appreciated.

Lloyd's suggestion works in this case, but it would fail in the event that
the value of the variable contained any single-quote characters.  A better
solution would be to swap the single and double quotes:

alias dfn='rxvt +sb -fn "$RXVTNEWSFONT" -geometry 128x51+69+42 ...'


  reply	other threads:[~2004-10-24  4:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-23 21:52 s. keeling
     [not found] ` <m3mzyd6pzp.fsf@asfast.com>
2004-10-23 23:14   ` s. keeling
2004-10-24  4:09     ` Bart Schaefer [this message]
2004-10-24  4:25       ` Lloyd Zusman
2004-10-24  4:51       ` s. keeling
2004-10-24 15:59         ` Bart Schaefer
2004-10-24 19:41           ` s. keeling

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=Pine.LNX.4.61.0410232057370.23496@toltec.zanshin.com \
    --to=schaefer@brasslantern.com \
    --cc=keeling@spots.ab.ca \
    --cc=zsh-users@sunsite.dk \
    /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).