zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: aliases in zsh -c and eval
Date: Thu, 27 Nov 2014 21:25:07 +0000	[thread overview]
Message-ID: <20141127212507.GA6057@chaz.gmail.com> (raw)
In-Reply-To: <20141127212221.GC5951@chaz.gmail.com>

2014-11-27 21:22:22 +0000, Stephane Chazelas:
> Hiya,
> 
> it looks like aliases defined in `zsh -c` are not expanded in
> there:
> 
> $ zsh -c 'alias foo=echo
> foo bar'
> zsh:2: command not found: foo
> 
> Those defined for instance in ~/.zshenv are expanded. And:
> 
> $ zsh -c 'alias foo=echo
> eval foo bar'
> bar
> 
> It looks like zsh is the only one out here. (with bash you need
> bash -O expand_aliases).
> 
> Same with eval:
> 
> $ (eval 'alias foo=echo
> subsh quote> foo bar')
> zsh: command not found: foo
> $ (eval 'alias foo=echo
> eval foo bar')
> bar
> 
> This time, ksh93 does behave like zsh.
[...]

For completeness:

$ cat > a
alias foo=echo
foo bar
$ zsh a
bar
$ zsh -c '. ./a'
bar
$ zsh -c 'eval "$(cat ./a)"'
(eval):2: command not found: foo
$ ksh a
bar
$ ksh -c '. ./a'
ksh: .[2]: foo: not found [No such file or directory]

ksh worse this time.

-- 
Stephane


  reply	other threads:[~2014-11-27 21:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-27 21:22 Stephane Chazelas
2014-11-27 21:25 ` Stephane Chazelas [this message]
2014-11-27 21:35 ` Mikael Magnusson
2014-11-27 21:35 ` Peter Stephenson

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=20141127212507.GA6057@chaz.gmail.com \
    --to=stephane.chazelas@gmail.com \
    --cc=zsh-workers@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).