zsh-workers
 help / color / mirror / code / Atom feed
* prompt compatibility
@ 1997-03-30 21:29 Zefram
  0 siblings, 0 replies; only message in thread
From: Zefram @ 1997-03-30 21:29 UTC (permalink / raw)
  To: zsh-workers

-----BEGIN PGP SIGNED MESSAGE-----

This patch adds two new options, for sh/ksh compatibility in prompt
expansion.  NO_PROMPT_PERCENT disables the % sequences, and is set in
sh/ksh emulation mode.  PROMPT_BANG enables ksh-like ! expansion (but
isn't quite a perfect emulation), and is set in ksh emulation mode.

 -zefram

 *** Doc/Zsh/compat.yo	1996/12/29 10:51:50	1.3
 --- Doc/Zsh/compat.yo	1997/03/30 16:55:56
 ***************
 *** 49,56 ****
   tt(KSH_ARRAYS),
   tt(NO_MULTIOS),
   tt(NO_NOMATCH),
 ! tt(RM_STAR_SILENT),
   tt(POSIX_BUILTINS),
   tt(SH_FILE_EXPANSION),
   tt(SH_GLOB),
   tt(SH_OPTION_LETTERS),
 --- 49,58 ----
   tt(KSH_ARRAYS),
   tt(NO_MULTIOS),
   tt(NO_NOMATCH),
 ! tt(NO_NOTIFY),
   tt(POSIX_BUILTINS),
 + tt(NO_PROMPT_PERCENT),
 + tt(RM_STAR_SILENT),
   tt(SH_FILE_EXPANSION),
   tt(SH_GLOB),
   tt(SH_OPTION_LETTERS),
 ***************
 *** 60,65 ****
 --- 62,68 ----
   Also, the
   tt(KSH_OPTION_PRINT),
   tt(LOCAL_OPTIONS),
 + tt(PROMPT_BANG),
   tt(PROMPT_SUBST)
   and
   tt(SINGLE_LINE_ZLE)
 *** Doc/Zsh/options.yo	1997/03/23 01:43:55	1.9
 --- Doc/Zsh/options.yo	1997/03/30 16:34:52
 ***************
 *** 634,646 ****
 --- 634,659 ----
   function always changes it globally regardless of the tt(LOCAL_OPTIONS)
   option.
   )
 + pindex(PROMPT_BANG)
 + cindex(prompt, ! expansion)
 + item(tt(PROMPT_BANG))(
 + If set, `tt(!)' is treated specially in prompt expansion.
 + See noderef(Prompt Expansion).
 + )
   pindex(PROMPT_CR)
   cindex(prompt, with CR)
   item(tt(PROMPT_CR) (tt(PLUS()V)))(
   Print a carriage return just before printing
   a prompt in the line editor.
   )
 + pindex(PROMPT_PERCENT)
 + cindex(prompt, % expansion)
 + item(tt(PROMPT_PERCENT))(
 + If set, `tt(%)' is treated specially in prompt expansion.
 + See noderef(Prompt Expansion).
 + )
   pindex(PROMPT_SUBST)
 + cindex(prompt, parameter expansion)
   item(tt(PROMPT_SUBST))(
   If set, em(parameter expansion), em(command substitution) and
   em(arithmetic expansion) are performed in prompts.
 *** Doc/Zsh/prompt.yo	1997/03/08 00:26:53	1.3
 --- Doc/Zsh/prompt.yo	1997/03/30 16:38:33
 ***************
 *** 19,26 ****
   noderef(Expansion).
   )\
   
 ! Certain escape sequences are recognised in the prompt string.
 ! These sequences start with `tt(%)'.
   Some escapes take an optional integer argument, which
   should appear between the `tt(%)' and the next character of the
   sequence.  The following escape sequences are recognized:
 --- 19,34 ----
   noderef(Expansion).
   )\
   
 ! Certain escape sequences may be recognised in the prompt string.
 ! 
 ! pindex(PROMPT_BANG, use of)
 ! If the tt(PROMPT_BANG) option is set, a `tt(!)' in the prompt is replaced
 ! by the current history event number.  A literal `tt(!)' may then be
 ! represented as `tt(!!)'.
 ! 
 ! pindex(PROMPT_PERCENT, use of)
 ! If the tt(PROMPT_PERCENT) option is set, certain escape sequences that
 ! start with `tt(%)' are expanded.
   Some escapes take an optional integer argument, which
   should appear between the `tt(%)' and the next character of the
   sequence.  The following escape sequences are recognized:
 *** Src/options.c	1997/03/23 01:44:07	1.8
 --- Src/options.c	1997/03/30 16:45:35
 ***************
 *** 144,150 ****
 --- 144,152 ----
   {NULL, "posixbuiltins",	      OPT_EMULATE|OPT_BOURNE,	 POSIXBUILTINS},
   {NULL, "printexitvalue",      0,			 PRINTEXITVALUE},
   {NULL, "privileged",	      OPT_SPECIAL,		 PRIVILEGED},
 + {NULL, "promptbang",	      OPT_EMULATE|OPT_KSH,	 PROMPTBANG},
   {NULL, "promptcr",	      OPT_ALL,			 PROMPTCR},
 + {NULL, "promptpercent",	      OPT_EMULATE|OPT_NONBOURNE, PROMPTPERCENT},
   {NULL, "promptsubst",	      OPT_EMULATE|OPT_KSH,	 PROMPTSUBST},
   {NULL, "pushdignoredups",     0,			 PUSHDIGNOREDUPS},
   {NULL, "pushdminus",	      0,			 PUSHDMINUS},
 *** Src/prompt.c	1997/03/26 09:09:23	1.10
 --- Src/prompt.c	1997/03/30 16:26:58
 ***************
 *** 114,122 ****
       return buf;
   }
   
 ! /* Perform %-expansion on a section of the prompt.  The section is ended by *
 !  * an instance of endchar.  If doprint is 0, the valid % sequences are      *
 !  * merely skipped over, and nothing is stored.                              */
   
   /**/
   int
 --- 114,122 ----
       return buf;
   }
   
 ! /* Perform %- and !-expansion as required on a section of the prompt.  The *
 !  * section is ended by an instance of endchar.  If doprint is 0, the valid *
 !  * % sequences are merely skipped over, and nothing is stored.             */
   
   /**/
   int
 ***************
 *** 130,136 ****
   
       for (; *fm && *fm != endchar; fm++) {
   	arg = 0;
 ! 	if (*fm == '%') {
   	    if (idigit(*++fm)) {
   		arg = zstrtol(fm, &fm, 10);
   	    }
 --- 130,136 ----
   
       for (; *fm && *fm != endchar; fm++) {
   	arg = 0;
 ! 	if (*fm == '%' && isset(PROMPTPERCENT)) {
   	    if (idigit(*++fm)) {
   		arg = zstrtol(fm, &fm, 10);
   	    }
 ***************
 *** 531,536 ****
 --- 531,547 ----
   		fm++;
   		break;
   	    }
 + 	} else if(*fm == '!' && isset(PROMPTBANG)) {
 + 	    if(doprint)
 + 		if(fm[1] == '!') {
 + 		    fm++;
 + 		    addbufspc(1);
 + 		    pputc('!');
 + 		} else {
 + 		    addbufspc(DIGBUFSIZE);
 + 		    sprintf(bp, "%d", curhist);
 + 		    bp += strlen(bp);
 + 		}
   	} else {
   	    char c = *fm == Meta ? *++fm ^ 32 : *fm;
   
 *** Src/zsh.h	1997/03/27 01:57:53	1.52
 --- Src/zsh.h	1997/03/30 16:15:50
 ***************
 *** 1032,1038 ****
 --- 1032,1040 ----
       POSIXBUILTINS,
       PRINTEXITVALUE,
       PRIVILEGED,
 +     PROMPTBANG,
       PROMPTCR,
 +     PROMPTPERCENT,
       PROMPTSUBST,
       PUSHDIGNOREDUPS,
       PUSHDMINUS,

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: ascii

iQCVAwUBMz6eHnD/+HJTpU/hAQHPugQAqtebJiSsN+T4NiXTSp+Le0SD8E4lTjqb
SzmZfrenlUgUi2mdnKhiCFuJ5VQr/aDq+XU73Q2O6Fd9hzOmPrgFeizWHA1cZwv4
6DEFPMjPnYCgRF9jx8zTxXarvl3VKCZCr7KSx+GJdyYQ1ZueMHU80LCgVAgfD0nh
SpTXdyC/L2A=
=ctrO
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-03-30 21:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-30 21:29 prompt compatibility Zefram

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