zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Treating alias or function arguments literally
Date: Thu, 15 Sep 2016 17:30:09 -0700	[thread overview]
Message-ID: <160915173009.ZM3818@torch.brasslantern.com> (raw)
In-Reply-To: <58b1b8df-7946-ba27-342f-d842dabd691d@nxvr.org>

On Sep 15,  4:20pm, zv wrote:
} Subject: Re: Treating alias or function arguments literally
}
} I have already declared this function `noglob' & `nocorrect'

This doesn't mean what you think it means.

Placing "setopt noglob nocorrect" *inside* a function DOES NOT affect
how the arguments of that function are interpreted.  Globbing occurs
as part of command line parsing before the function even begins to
execute.

The point of

  alias calc='noglob calc'

is to tell the command line parser not to perform globbing on that
command line, which will then protect the arguments.

} (I just checked with an alias and that doesn't effect it either)

In fact in my own .zshrc I have (dating back years to before zsh
had floating-point math in $(( )) expressions):

  calc () {
    awk "BEGIN {print $*}" < /dev/null
  }
  alias calc='noglob calc'

And it works exacly as intended:

schaefer<501> calc 4*3
12
schaefer<502> calc 20*15/2
150
schaefer<503> 

So ... what alias are you using that doesn't work?  Note that you have
to assign the alias *after* defining the function, or weird things
will result (see the FAQ).


      reply	other threads:[~2016-09-16  0:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-15 21:47 zv
2016-09-15 22:48 ` Jérémie Roquet
2016-09-15 23:20   ` zv
2016-09-16  0:30     ` Bart Schaefer [this message]

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=160915173009.ZM3818@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).