zsh-users
 help / color / mirror / code / Atom feed
* Seeking feedback word breaks and aliasing of tokens
@ 2015-03-27 16:05 Bart Schaefer
  2015-03-28 23:58 ` Eric Cook
  2015-05-15  0:41 ` Oliver Kiddle
  0 siblings, 2 replies; 8+ messages in thread
From: Bart Schaefer @ 2015-03-27 16:05 UTC (permalink / raw)
  To: zsh-users

Following a discussion a few weeks ago, a new feature was added to the
"alias" builtin, namely the ability to create aliases for tokens that
are part of the basic pipeline syntax.  The example that led to this
feature was similar to the following:

% alias -g '&&'='; (( $? == 0 )) && '
% && print this is OK
this is OK
% && print and so is this && print also this
and so is this
also this
% 

This feature has already been adopted, with the restrictions (a) that it
applies only to global aliases [-g] and (b) that it is disabled when the
POSIX_ALIASES option is set.

There is an additional effect of this feature, illustrated by:

% alias -g '||'='OR'
% print no||yes
no ORyes
% 

Note that a word break is introduced to the left of the expansion (because
of '||'s original meaning as shell syntax) even though there are no spaces
around the original usage; but no word break occurs to the right of the
expansion.  The proposal is for word breaks on both sides of the expansion
(as is implied by recognition of a separately aliasable word).

This also affects the '{' reserved word, so instead of this:

% alias '{'=echo
% { OK
OK
% {not OK
zsh: command not found: echonot
% 

We would have this:

% {now OK
now OK
% 

(Note that '{' doesn't require "alias -g" because '{' is a reserved word.)

Comments welcome.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-05-15  1:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-27 16:05 Seeking feedback word breaks and aliasing of tokens Bart Schaefer
2015-03-28 23:58 ` Eric Cook
2015-03-29  4:19   ` Bart Schaefer
2015-03-29  4:47     ` Bart Schaefer
2015-03-29 17:09     ` Eric Cook
2015-03-29 21:02       ` Bart Schaefer
2015-05-15  0:41 ` Oliver Kiddle
2015-05-15  1:35   ` Bart Schaefer

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).