zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: PATCH: perform expansion for precommand modifiers
Date: Fri, 28 Apr 2017 10:03:38 +0100	[thread overview]
Message-ID: <20170428100338.27ef869c@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <170427161300.ZM23462@torch.brasslantern.com>

On Thu, 27 Apr 2017 16:12:59 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Apr 27,  9:40am, Peter Stephenson wrote:
> }
> } +  (\exec /bin/sh -c 'echo Test one'; print Not reached)
> } +  ('exec' /bin/sh -c 'echo Test two'; print Not reached)
> } +0:exec with quotes
> } +>Test one
> } +>Test two
> 
> This isn't testing the right thing.  The complaint was that the -c option
> of exec was treated as a command name if the keyword was quoted.

I think we can fix this by adding a test for that.

> Similarly for "command -p" which now that I try it is still broken:
> 
> torch% \command -p echo
> zsh: command not found: -p

That's nothing to do with the quoting.  I assumed we had a test for -p
without -v or -V, but apparently we don't, so I didn't notice there was
an extra node to remove.

pws

diff --git a/Src/exec.c b/Src/exec.c
index 978a32d..15f663c 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2824,7 +2824,7 @@ execcmd_exec(Estate state, Execcmd_params eparams,
 		 * Otherwise, just leave marked as BINF_COMMAND
 		 * modifier with no additional action.
 		 */
-		LinkNode argnode, oldnode;
+		LinkNode argnode, oldnode, pnode = NULL;
 		char *argdata, *cmdopt;
 		int has_p = 0, has_vV = 0, has_other = 0;
 		argnode = firstnode(preargs);
@@ -2845,6 +2845,7 @@ execcmd_exec(Estate state, Execcmd_params eparams,
 			     * also traditional behaviour.
 			     */
 			    has_p = 1;
+			    pnode = argnode;
 			    break;
 			case 'v':
 			case 'V':
@@ -2882,6 +2883,12 @@ execcmd_exec(Estate state, Execcmd_params eparams,
 		} else if (has_p) {
 		    /* Use default path */
 		    use_defpath = 1;
+		    /*
+		     * We don't need this node as we're not treating
+		     * "command" as a builtin this time.
+		     */
+		    if (pnode)
+			uremnode(preargs, pnode);
 		}
 		/*
 		 * Else just any trailing
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 37311ce..9625a15 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -116,9 +116,11 @@
 
   (\exec /bin/sh -c 'echo Test one'; print Not reached)
   ('exec' /bin/sh -c 'echo Test two'; print Not reached)
-0:exec with quotes
+  (\exec -c /bin/sh -c 'echo Test three'; print Not reached)
+0:precommand modifiers with quotes
 >Test one
 >Test two
+>Test three
 
   cat() { echo Function cat executed; }
   command cat && unfunction cat
@@ -126,6 +128,14 @@
 <External command cat executed
 >External command cat executed
 
+  (command -p echo this is output)
+  (\command -p echo this is more output)
+  ('command' -p echo this is yet more output)
+0: command -p without -v or -V
+>this is output
+>this is more output
+>this is yet more output
+
   command -pv cat
   command -pv echo
   command -p -V cat


  reply	other threads:[~2017-04-28  9:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170425091533eucas1p26af70366557848059af3b7c8957f1d55@eucas1p2.samsung.com>
2017-04-25  9:15 ` Peter Stephenson
2017-04-26 19:45   ` Daniel Shahaf
2017-04-26 21:25     ` Bart Schaefer
2017-04-27  8:40       ` Peter Stephenson
2017-04-27 23:12         ` Bart Schaefer
2017-04-28  9:03           ` Peter Stephenson [this message]
2017-05-01 18:31             ` Daniel Shahaf

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=20170428100338.27ef869c@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.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).