Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Colon qualifiers with ^...^...^



Someone pointed out that history substitution in the ^...^...^ form
doesn't allow extra qualifiers at the end any more... this was only
because I didn't know it worked before.  Fixing it turns out to be
trivial.  This patch (despite its length) does nothing more than
reposition the closing brace after the test for the ^ form, so there's
no overhead in fixing it at all.  All the other changes are indentation.

% print foo
foo
% ^print^echo^:s/foo/bar/
echo bar
bar

I assume this is what is meant:  I don't think allowing word
selections from the just-substituted line is on at this point.

I don't think this depends on my long history fix.

*** Src/hist.c~	Wed Nov  8 09:25:47 1995
--- Src/hist.c	Tue Nov 14 13:20:05 1995
***************
*** 322,412 ****
  	if (!(sline = getargs(ehist, farg, larg)))
  	    return -1;
  
! 	/* do the modifiers */
  
! 	for (;;) {
! 	    c = (cflag) ? ':' : ingetc();
! 	    cflag = 0;
! 	    if (c == ':') {
! 		int gbal = 0;
  
! 		if ((c = ingetc()) == 'g') {
! 		    gbal = 1;
! 		    c = ingetc();
  		}
! 		switch (c) {
! 		case 'p':
! 		    histdone = HISTFLAG_DONE | HISTFLAG_NOEXEC;
! 		    break;
! 		case 'h':
! 		    if (!remtpath(&sline)) {
! 			inerrflush();
! 			zerr("modifier failed: h", NULL, 0);
! 			return -1;
! 		    }
! 		    break;
! 		case 'e':
! 		    if (!rembutext(&sline)) {
! 			inerrflush();
! 			zerr("modifier failed: e", NULL, 0);
! 			return -1;
! 		    }
! 		    break;
! 		case 'r':
! 		    if (!remtext(&sline)) {
! 			inerrflush();
! 			zerr("modifier failed: r", NULL, 0);
! 			return -1;
! 		    }
! 		    break;
! 		case 't':
! 		    if (!remlpaths(&sline)) {
! 			inerrflush();
! 			zerr("modifier failed: t", NULL, 0);
! 			return -1;
! 		    }
! 		    break;
! 		case 's':
! 		    if (getsubsargs(sline))
! 			return -1; /* fall through */
! 		case '&':
! 		    if (hsubl && hsubr)
! 			subst(&sline, hsubl, hsubr, gbal);
! 		    else {
! 			inerrflush();
! 			zerr("no previous substitution with &", NULL, 0);
! 			return -1;
! 		    }
! 		    break;
! 		case 'q':
! 		    quote(&sline);
! 		    break;
! 		case 'x':
! 		    quotebreak(&sline);
! 		    break;
! 		case 'l':
! 		    downcase(&sline);
! 		    break;
! 		case 'u':
! 		    upcase(&sline);
! 		    break;
! 		default:
  		    inerrflush();
! 		    zerr("illegal modifier: %c", NULL, c);
  		    return -1;
  		}
! 	    } else {
! 		if (c != '}' || !bflag)
! 		    inungetc(c);
! 		if (c != '}' && bflag) {
! 		    zerr("'}' expected", NULL, 0);
  		    return -1;
  		}
  		break;
  	    }
  	}
- 
      }
      /*
       * Push the expanded value onto the input stack,
       * marking this as a history word for purposes of the alias stack.
--- 322,412 ----
  	if (!(sline = getargs(ehist, farg, larg)))
  	    return -1;
  
!     }
!     /* do the modifiers */
  
!     for (;;) {
! 	c = (cflag) ? ':' : ingetc();
! 	cflag = 0;
! 	if (c == ':') {
! 	    int gbal = 0;
  
! 	    if ((c = ingetc()) == 'g') {
! 		gbal = 1;
! 		c = ingetc();
! 	    }
! 	    switch (c) {
! 	    case 'p':
! 		histdone = HISTFLAG_DONE | HISTFLAG_NOEXEC;
! 		break;
! 	    case 'h':
! 		if (!remtpath(&sline)) {
! 		    inerrflush();
! 		    zerr("modifier failed: h", NULL, 0);
! 		    return -1;
! 		}
! 		break;
! 	    case 'e':
! 		if (!rembutext(&sline)) {
! 		    inerrflush();
! 		    zerr("modifier failed: e", NULL, 0);
! 		    return -1;
! 		}
! 		break;
! 	    case 'r':
! 		if (!remtext(&sline)) {
! 		    inerrflush();
! 		    zerr("modifier failed: r", NULL, 0);
! 		    return -1;
  		}
! 		break;
! 	    case 't':
! 		if (!remlpaths(&sline)) {
  		    inerrflush();
! 		    zerr("modifier failed: t", NULL, 0);
  		    return -1;
  		}
! 		break;
! 	    case 's':
! 		if (getsubsargs(sline))
! 		    return -1;	/* fall through */
! 	    case '&':
! 		if (hsubl && hsubr)
! 		    subst(&sline, hsubl, hsubr, gbal);
! 		else {
! 		    inerrflush();
! 		    zerr("no previous substitution with &", NULL, 0);
  		    return -1;
  		}
  		break;
+ 	    case 'q':
+ 		quote(&sline);
+ 		break;
+ 	    case 'x':
+ 		quotebreak(&sline);
+ 		break;
+ 	    case 'l':
+ 		downcase(&sline);
+ 		break;
+ 	    case 'u':
+ 		upcase(&sline);
+ 		break;
+ 	    default:
+ 		inerrflush();
+ 		zerr("illegal modifier: %c", NULL, c);
+ 		return -1;
+ 	    }
+ 	} else {
+ 	    if (c != '}' || !bflag)
+ 		inungetc(c);
+ 	    if (c != '}' && bflag) {
+ 		zerr("'}' expected", NULL, 0);
+ 		return -1;
  	    }
+ 	    break;
  	}
      }
+ 
      /*
       * Push the expanded value onto the input stack,
       * marking this as a history word for purposes of the alias stack.

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



Messages sorted by: Reverse Date, Date, Thread, Author