From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22203 invoked by alias); 26 Mar 2015 03:43:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34781 Received: (qmail 16482 invoked from network); 26 Mar 2015 03:43:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=OTmjJMRoPgPfIamL1loAvj8KRwBcGdNrXWLSpQiBFgI=; b=i4ouBaOLql1Xv2pF1qE3dbW9azgV5hH9IQh4bymnS6UUYLCLClmPiat4IZm3UmebxK BnaC7bfcevOvIe+SgEJPKiHoeP2X0rhe1H/yWJfmKDkNwVSJDfiC2QjX9D1zaLGNiU2L SX+ee3oMbvLQ0WyV30CoJwZ7Kwl0sfaqZZVyQiEuUW79N9Zyf5vu9TbHACZOVAXmkVyq QT4NqY8AN5IEmszTy7p1kCKt8vhKrigfyvktapI4IzrVDPPu8SZJF60etOHqyoASMZKT nQ4MjGm9koveT7u89mephGrM3bcMSHjG2ewXuoRY8eBIwvBsRvyI+jAeuAuZ9msukSXx 23iA== X-Gm-Message-State: ALoCoQlVb4cXm77jnka8VVLnpQWtCgSvn/vEDwTQoyGc8ijFolPZ7y6wlumRV+WKBgV1ml8QDM5G X-Received: by 10.60.63.39 with SMTP id d7mr10247483oes.72.1427341388804; Wed, 25 Mar 2015 20:43:08 -0700 (PDT) From: Bart Schaefer Message-Id: <150325204305.ZM1653@torch.brasslantern.com> Date: Wed, 25 Mar 2015 20:43:05 -0700 In-Reply-To: <150325124032.ZM32185@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working)" (Mar 25, 12:40pm) References: <20150319105716.620cd931@pwslap01u.europe.root.pri> <20150319125351.1e270c2d@pwslap01u.europe.root.pri> <20150320105703.2754b6af@pwslap01u.europe.root.pri> <150320090420.ZM21908@torch.brasslantern.com> <20150322183556.1fa0f143@ntlworld.com> <150322162235.ZM1728@torch.brasslantern.com> <20150323213426.21fd79c8@ntlworld.com> <20150325154853.7efc21d0@pwslap01u.europe.root.pri> <150325124032.ZM32185@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "Zsh Hackers' List" Subject: Word breaks around aliased tokens (was Re: PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working)) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 25, 12:40pm, Bart Schaefer wrote: } } torch% echo foo&&bar } foo foobar } } If this were going to change, I would recommend using something akin to } my patch from workers/34738 to add the second space, rather than attempt } to remove the first one. That would be as below, which is almost identical to 34738 (the salient difference being use of INP_ALIAS instead of INP_CONT). I think this makes sense[*]: torch% alias -g '&&'=AND torch% echo foo&&bar foo AND bar (the pre-patch output is "foo ANDbar") but I will wait for feedback before pushing. [*] To the extent I think aliasing these tokens makes sense at all. diff --git a/Src/lex.c b/Src/lex.c index 6d0079c..4c1555e 100644 --- a/Src/lex.c +++ b/Src/lex.c @@ -1747,6 +1747,16 @@ checkalias(void) if (an && !an->inuse && ((an->node.flags & ALIAS_GLOBAL) || (incmdpos && tok == STRING) || inalmore)) { + if (!lexstop) { + /* + * Tokens that don't require a space after, get one, + * because they are treated as if preceded by one. + */ + int c = hgetc(); + hungetc(c); + if (!iblank(c)) + inpush(" ", INP_ALIAS, 0); + } inpush(an->text, INP_ALIAS, an); if (an->text[0] == ' ' && !(an->node.flags & ALIAS_GLOBAL)) aliasspaceflag = 1; diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst index fe7155e..08163eb 100644 --- a/Test/A02alias.ztst +++ b/Test/A02alias.ztst @@ -67,7 +67,7 @@ fc -l -2' 2>/dev/null 0:Aliasing reserved tokens >begin ->zsh: command not found: echoend +>end *>*4*{ begin *>*5*{end