zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <A.Main@dcs.warwick.ac.uk>
To: zsh-workers@math.gatech.edu (Z Shell workers mailing list)
Subject: Re: Rationalized? aliases
Date: Thu, 9 Nov 1995 02:12:35 +0000 (GMT)	[thread overview]
Message-ID: <19823.199511090212@stone.dcs.warwick.ac.uk> (raw)
In-Reply-To: <199511082317.SAA29367@redwood.skiles.gatech.edu> from "Richard Coleman" at Nov 8, 95 06:17:19 pm

>Hmm... A quick fix for your problem is to change
>printaliasnode() in hashtable.c so that when the flags
>PRINT_WHENCE_* are present, that it will use printf (or puts)
>instead of printquoted().  This is exactly how it was done in
>beta10.  But is this what we want to do?  It looks natural for
>the output of `type' and `which' to be quoted.  For `whence' it
>is not quite so clear which is best.

"whence" is supposed to be used by humans.  Its output should be
quoted.  Putting it in a command substitution is, and always was, a
kludge.  That's what equals substitution is for:

% alias foo=bar
% echo =foo
bar

but there is an inconsistency, in a way, between equals substitution of
normal commands and of aliases:

% whence 'a*b'
/dcs/94/zefram/bin/a*b
% echo ='a*b'
/dcs/94/zefram/bin/a*b
% ='a*b'
This is a script with a silly name.
% alias foobar='echo *'
% echo =foobar
echo *
% =foobar
zsh: command not found: echo *

Actually the inconsistency is not in the equals substitution itself,
but in the fact that the text it expands to will, in actual use, be
rescanned.  This limits the use of equals substitution a little.

I think for builtins and shell functions equals substitution should
expand to the command name, rather than its present behaviour of
failing.  Then equals substitution will be usable in functions in an
interesting way:

function foo {
  local savecmd==$1 evalhack=
  alias $1 >&- && evalhack=eval
  # some commands that mess up PATH or whatever
  $=evalhack $savecmd some args
  # more commands
}

Maybe there should be another syntax similar to equals substitution --
say, ==command -- that puts an extra layer of quoting on the
substituted filename unless the command is an alias.  That would make
the above function:

function foo {
  local savecmd===$1 evalhack=
  # some commands that mess up PATH or whatever
  alias savedcmd=$savecmd
  savedcmd some args
  # more commands
}

Anyone got any better ideas?

-zefram


      parent reply	other threads:[~1995-11-09  2:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-11-08 20:57 Vinnie Shelton
1995-11-08 23:17 ` Richard Coleman
1995-11-08 23:36   ` Barton E. Schaefer
1995-11-09  0:52     ` Mark Borges
1995-11-09  1:07       ` Barton E. Schaefer
1995-11-09 11:13       ` Zoltan Hidvegi
1995-11-08 23:38   ` Vinnie Shelton
1995-11-09  2:12   ` Zefram [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=19823.199511090212@stone.dcs.warwick.ac.uk \
    --to=a.main@dcs.warwick.ac.uk \
    --cc=zsh-workers@math.gatech.edu \
    /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).