zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: bufferwords() lexes a subshell in a shortloop repeat as a string
Date: Mon, 18 Jan 2016 16:32:55 -0800	[thread overview]
Message-ID: <160118163255.ZM3369@torch.brasslantern.com> (raw)
In-Reply-To: <20160118165237.11b1349a@pwslap01u.europe.root.pri>

On Jan 18,  4:52pm, Peter Stephenson wrote:
} Subject: Re: bufferwords() lexes a subshell in a shortloop repeat as a str
}
} On Mon, 18 Jan 2016 08:36:58 -0800
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} > print -l one (two three|foo) four
} 
} I was trying it with the (z) flag, which does cause the word to be
} split up, not directly at the command line, where I get what you get.
} 
} I don't know why they'd be different, offhand.

Seems to be that parameter substitution applies shwordsplit before (z)
gets involved, so we have separate calls to bufferwords() for each of
"one", "(two", "three|foo)" and "four".

Directly at command line, gettok() returns "\210two three\216four\212".

Does the below look correct?

schaefer[573] ARGV0=sh Src/zsh -f
$ print one (two three|four) five
zsh: parse error near `('
$ 


diff --git a/Src/lex.c b/Src/lex.c
index 0f260d0..c21ef2d 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -801,7 +801,7 @@ gettok(void)
 	    return INOUTPAR;
 	hungetc(d);
 	lexstop = 0;
-	if (!(incond == 1 || incmdpos))
+	if (!(isset(SHGLOB) || incond == 1 || incmdpos))
 	    break;
 	return INPAR;
     case LX1_OUTPAR:


Aside:  "emulate sh" does the equivalent of

    setopt shglob noglob nokshglob

In order to make kshglob work, one must

    setopt glob kshglob

Is that correct, or should only kshglob be needed?


  reply	other threads:[~2016-01-19  0:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-15  6:26 Daniel Shahaf
2016-01-15  9:41 ` Peter Stephenson
2016-01-15 19:25   ` Bart Schaefer
2016-01-17 18:16     ` Peter Stephenson
2016-01-17 22:46       ` Bart Schaefer
2016-01-18  9:41         ` Peter Stephenson
2016-01-18 16:36           ` Bart Schaefer
2016-01-18 16:52             ` Peter Stephenson
2016-01-19  0:32               ` Bart Schaefer [this message]
2016-01-19  3:29                 ` Bart Schaefer
2016-01-19  4:07                   ` kshglob + noglob (was Re: bufferwords() lexes ....) Bart Schaefer
2016-01-19  9:36                 ` bufferwords() lexes a subshell in a shortloop repeat as a string Peter Stephenson
2016-01-19 18:59                   ` Bart Schaefer
2016-01-18  2:25   ` Daniel Shahaf
2016-01-18 10:45     ` Peter Stephenson
2016-01-20  7:47       ` Daniel Shahaf
2016-01-20 15:59         ` Bart Schaefer
2016-01-21  6:50           ` Bart Schaefer
2016-01-23 23:53           ` Daniel Shahaf
2016-01-24  5:56             ` Bart Schaefer
2016-01-19  4:56     ` Bart Schaefer
2016-01-20  7:47       ` 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=160118163255.ZM3369@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).