zsh-workers
 help / color / mirror / code / Atom feed
* parse errors and up-line-or-history
@ 2000-10-17 19:35 E. Jay Berkenbilt
  2000-10-17 21:21 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: E. Jay Berkenbilt @ 2000-10-17 19:35 UTC (permalink / raw)
  To: zsh-workers


If you type

zsh% for in *; do echo $i; done

(instead of for i in *...; i.e., forget the variable name in the for)

you get 

zsh: parse error near `do'

which seems entirely reasonable.  If you then do ^p to fix it, you see
only

zsh% for in *; do

and not the whole command.  It would be nice if the whole command
including whatever part appears after the parse error got inserted
into history since it would be much easier to go back and fix the
typo. :-)

--
E. Jay Berkenbilt (ejb@ql.org)  |  http://www.ql.org/q/


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

* Re: parse errors and up-line-or-history
  2000-10-17 19:35 parse errors and up-line-or-history E. Jay Berkenbilt
@ 2000-10-17 21:21 ` Bart Schaefer
  2000-10-17 23:03   ` E. Jay Berkenbilt
  2000-10-18  9:08   ` Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Bart Schaefer @ 2000-10-17 21:21 UTC (permalink / raw)
  To: E. Jay Berkenbilt, zsh-workers

On Oct 17,  3:35pm, E. Jay Berkenbilt wrote:
> 
> zsh% for in *; do echo $i; done
> zsh: parse error near `do'
> 
> which seems entirely reasonable.  If you then do ^p to fix it, you see
> only
> 
> zsh% for in *; do
> 
> and not the whole command.

Congratulations, you've revived the "literal vs. lexical history" debate,
if it ever really was a debate.

Zsh used to have an option to store the command history as the literal
input text, rather than as lexical words.  IIRC, it actually stored both
and let you select which one to retrieve.  The duplication was resolved
in favor of lexical history a *very* long time ago, with the side-effect
that anything that won't lex, doesn't make it into the history.

For a partial workaround, see zsh-workers/10996.


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

* Re: parse errors and up-line-or-history
  2000-10-17 21:21 ` Bart Schaefer
@ 2000-10-17 23:03   ` E. Jay Berkenbilt
  2000-10-18  9:08   ` Peter Stephenson
  1 sibling, 0 replies; 6+ messages in thread
From: E. Jay Berkenbilt @ 2000-10-17 23:03 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-workers


>   > zsh% for in *; do echo $i; done
>   > zsh: parse error near `do'
>   > 
>   > which seems entirely reasonable.  If you then do ^p to fix it, you see
>   > only
>   > 
>   > zsh% for in *; do
>   > 
>   > and not the whole command.
>
>   Congratulations, you've revived the "literal vs. lexical history" debate,
>   if it ever really was a debate.
>
>   Zsh used to have an option to store the command history as the literal
>   input text, rather than as lexical words.  IIRC, it actually stored both
>   and let you select which one to retrieve.  The duplication was resolved
>   in favor of lexical history a *very* long time ago, with the side-effect
>   that anything that won't lex, doesn't make it into the history.
>
>   For a partial workaround, see zsh-workers/10996.

This workaround does exactly what I want.  I just bound your
zle-fetch-previous and zle-fetch-next to ^x^p and ^x^n respectively so
I get the benefits of the lexical history except when I really want
the other in which case I can specify it directly.  Thanks.

                                Jay


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

* Re: parse errors and up-line-or-history
  2000-10-17 21:21 ` Bart Schaefer
  2000-10-17 23:03   ` E. Jay Berkenbilt
@ 2000-10-18  9:08   ` Peter Stephenson
  2000-10-18 15:38     ` Bart Schaefer
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2000-10-18  9:08 UTC (permalink / raw)
  To: Zsh hackers list

Bart wrote:
> On Oct 17,  3:35pm, E. Jay Berkenbilt wrote:
> > 
> > zsh% for in *; do echo $i; done
> > zsh: parse error near `do'
> > 
> > which seems entirely reasonable.  If you then do ^p to fix it, you see
> > only
> > 
> > zsh% for in *; do
> > 
> > and not the whole command.
>
> Zsh used to have an option to store the command history as the literal
> input text, rather than as lexical words.  IIRC, it actually stored both
> and let you select which one to retrieve.  The duplication was resolved
> in favor of lexical history a *very* long time ago, with the side-effect
> that anything that won't lex, doesn't make it into the history.

There was originally a partial fix that the rest of the line gets read in
and stuck on the end of the history without lexing.  I haven't looked at
this for a long time, so it may be at the mercy of various flags which
abort what you're doing.  It might be possible to get it working.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


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

* Re: parse errors and up-line-or-history
  2000-10-18  9:08   ` Peter Stephenson
@ 2000-10-18 15:38     ` Bart Schaefer
  2000-10-19  7:10       ` Wayne Davison
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2000-10-18 15:38 UTC (permalink / raw)
  To: Zsh hackers list

On Oct 18, 10:08am, Peter Stephenson wrote:
}
} Bart wrote:
} > that anything that won't lex, doesn't make it into the history.
} 
} There was originally a partial fix that the rest of the line gets read in
} and stuck on the end of the history without lexing.  I haven't looked at
} this for a long time, so it may be at the mercy of various flags

Aha!  It's HIST_REDUCE_BLANKS!  Unset that option, and the entire command
line makes it into the history.

Wayne, are you listening?

The other stuff I talked about in 10996, e.g. editing the line from before
history expansion was done, still applies.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: parse errors and up-line-or-history
  2000-10-18 15:38     ` Bart Schaefer
@ 2000-10-19  7:10       ` Wayne Davison
  0 siblings, 0 replies; 6+ messages in thread
From: Wayne Davison @ 2000-10-19  7:10 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list

On Wed, 18 Oct 2000, Bart Schaefer wrote:
> Aha!  It's HIST_REDUCE_BLANKS!  Unset that option, and the entire command
> line makes it into the history.

Yes, histreduceblanks() expects all the content on the line to be
represented in the chwords[] array so that it can tell which spaces are
significant and which aren't.  There are a few solutions I can think of.
One would be to add the unparsed part of the line to chwords[].  Another
would be to have histreduceblanks() notice the extra content beyond the
last chwords[] item and preserve it.  The easiest one, though, is to not
try to reduce the blanks on a line that didn't parse right.  I opted for
this last solution for now:

Index: Src/hist.c
@@ -1063,11 +1063,12 @@
 	}
 #endif
 	/* get rid of pesky \n which we've already nulled out */
-	if (chwordpos > 1 && !chline[chwords[chwordpos-2]])
+	if (chwordpos > 1 && !chline[chwords[chwordpos-2]]) {
 	    chwordpos -= 2;
-	/* strip superfluous blanks, if desired */
-	if (isset(HISTREDUCEBLANKS))
-	    histreduceblanks();
+	    /* strip superfluous blanks, if desired */
+	    if (isset(HISTREDUCEBLANKS))
+		histreduceblanks();
+	}
 	if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && he
 	 && histstrcmp(chline, he->text) == 0) {
 	    /* This history entry compares the same as the previous.

I've tested this, and it appears to work fine, so I think I'll go ahead
and check it in.

..wayne..


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

end of thread, other threads:[~2000-10-19  7:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-17 19:35 parse errors and up-line-or-history E. Jay Berkenbilt
2000-10-17 21:21 ` Bart Schaefer
2000-10-17 23:03   ` E. Jay Berkenbilt
2000-10-18  9:08   ` Peter Stephenson
2000-10-18 15:38     ` Bart Schaefer
2000-10-19  7:10       ` Wayne Davison

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