diff --git a/COPYRIGHT b/COPYRIGHT index af6080aac602..4a5f31b6192c 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -28,6 +28,7 @@ ksh 93u+m general copyright notice # Chase # # rymrg <54061433+rymrg@users.noreply.github.com> # # hyousatsu <118750527+hyousatsu@users.noreply.github.com> # +# dnewhall # # Trey Valenta # # Sterling Jensen <5555776+sterlingjensen@users.noreply.github.com> # # Marc Wilson # diff --git a/src/cmd/builtin/Mamfile b/src/cmd/builtin/Mamfile index d3bc86d61d4a..d75ac164d8b2 100644 --- a/src/cmd/builtin/Mamfile +++ b/src/cmd/builtin/Mamfile @@ -14,14 +14,14 @@ setv IFFEFLAGS setv LDFLAGS make install virtual - bind -lcmd - bind -lutil dontcare note * note * Build pty note * make pty + bind -lcmd + bind -lutil dontcare make pty.o make pty.c make FEATURE/pty diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index 9783ffe98bba..56fac2d70e0c 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -10,7 +10,9 @@ * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html * * (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) * * * +* Michael T. Veach * * David Korn * +* Matthijs N. Melchior * * Martijn Dekker * * Johnothan King * * K. Eugene Carlson * @@ -33,9 +35,6 @@ One line screen editor for any program * HV BZ335 x2962 * hvlpb!mmelchio * - * These are now on by default - * - * ESH_NFIRST * - A ^N as first history related command after the prompt will move * to the next command relative to the last known history position. * It will not start at the position where the last command was entered @@ -43,20 +42,15 @@ One line screen editor for any program * set both the current and last position. Executing a command will * only set the current position. * - * ESH_KAPPEND * - Successive kill and delete commands will accumulate their data * in the kill buffer, by appending or prepending as appropriate. * This mode will be reset by any command not adding something to the * kill buffer. * - * ESH_BETTER * - Some enhancements: * - argument for a macro is passed to its replacement * - ^X^H command to find out about history position (debugging) * - ^X^D command to show any debugging info - * - * I do not pretend these for changes are completely independent, - * but you can use them to separate features. */ #include "shopt.h" @@ -74,10 +68,6 @@ One line screen editor for any program #endif /* SHOPT_MULTIBYTE */ #include -#define ESH_NFIRST -#define ESH_KAPPEND -#define ESH_BETTER - #undef putchar #define putchar(ed,c) ed_putchar(ed,c) #define beep() ed_ringbell() @@ -219,7 +209,6 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) kstack[0] = '\0'; } drawbuff = out; -#ifdef ESH_NFIRST if (location.hist_command == -5) /* to be initialized */ { kstack[0] = '\0'; /* also clear kstack... */ @@ -232,7 +221,6 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) location.hist_line = 0; } ep->in_mult = hloff; /* save pos in last command */ -#endif /* ESH_NFIRST */ i = sigsetjmp(env,0); if (i !=0) { @@ -258,23 +246,7 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) adjust = -1; backslash = 0; if (ep->CntrlO) - { -#ifdef ESH_NFIRST ed_ungetchar(ep->ed,cntl('N')); -#else - location = hist_locate(sh.hist_ptr,location.hist_command,location.hist_line,1); - if (location.hist_command < histlines) - { - hline = location.hist_command; - hloff = location.hist_line; - hist_copy((char*)kstack,MAXLINE, hline,hloff); -# if SHOPT_MULTIBYTE - ed_internal((char*)kstack,kstack); -# endif /* SHOPT_MULTIBYTE */ - ed_ungetchar(ep->ed,cntl('Y')); - } -#endif /* ESH_NFIRST */ - } ep->CntrlO = 0; while ((c = ed_getchar(ep->ed,backslash)) != (-1)) { @@ -309,10 +281,8 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) { c = EOFCHAR; } -#ifdef ESH_KAPPEND if (--killing <= 0) /* reset killing flag */ killing = 0; -#endif oadjust = count = adjust; if(count<0) count = 1; @@ -412,7 +382,6 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) case ERASECHAR : if (count > i) count = i; -#ifdef ESH_KAPPEND kptr = &kstack[count]; /* move old contents here */ if (killing) /* prepend to killbuf */ { @@ -426,22 +395,11 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) i -= count; eol -= count; genncpy(kstack,out+i,cur-i); -#else - while ((count--)&&(i>0)) - { - i--; - eol--; - } - genncpy(kstack,out+i,cur-i); - kstack[cur-i] = 0; -#endif /* ESH_KAPPEND */ gencpy(out+i,out+cur); ep->mark = i; goto update; case cntl('W') : -#ifdef ESH_KAPPEND ++killing; /* keep killing flag */ -#endif if (ep->mark > eol ) ep->mark = eol; if (ep->mark == i) @@ -457,15 +415,11 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) continue; case cntl('D') : ep->mark = i; -#ifdef ESH_KAPPEND if (killing) kptr = &kstack[genlen(kstack)]; /* append here */ else kptr = kstack; killing = 2; /* we are now killing */ -#else - kptr = kstack; -#endif /* ESH_KAPPEND */ while ((count--)&&(eol>0)&&(i= 0) { -#ifdef ESH_KAPPEND killing = 2; /* set killing signal */ -#endif ep->mark = count; ed_ungetchar(ep->ed,cntl('W')); continue; @@ -579,15 +531,11 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) i = cur; eol = i; ep->mark = i; -#ifdef ESH_KAPPEND if (killing) /* append to kill buffer */ gencpy(&kstack[genlen(kstack)], &out[i]); else gencpy(kstack,&out[i]); killing = 2; /* set killing signal */ -#else - gencpy(kstack,&out[i]); -#endif /* ESH_KAPPEND */ out[i] = 0; draw(ep,UPDATE); continue; @@ -615,11 +563,7 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) hline -= count - hloff; hloff = 0; } -#ifdef ESH_NFIRST if (hline <= hismin) -#else - if (hline < hismin) -#endif /* ESH_NFIRST */ { hline = hismin+1; beep(); @@ -634,28 +578,20 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) c = '\n'; goto process; case cntl('N') : -#ifdef ESH_NFIRST hline = location.hist_command; /* start at saved position */ hloff = location.hist_line; -#endif /* ESH_NFIRST */ location = hist_locate(sh.hist_ptr,hline,hloff,count); if (location.hist_command > histlines) { beep(); -#ifdef ESH_NFIRST location.hist_command = histlines; location.hist_line = ep->in_mult; -#else - continue; -#endif /* ESH_NFIRST */ } hline = location.hist_command; hloff = location.hist_line; common: -#ifdef ESH_NFIRST location.hist_command = hline; /* save current position */ location.hist_line = hloff; -#endif cur = 0; draw(ep,UPDATE); hist_copy((char*)out,MAXLINE, hline,hloff); @@ -746,9 +682,7 @@ static int escape(Emacs_t* ep,genchar *out,int count) if (digit) { ed_ungetchar(ep->ed,i) ; -#ifdef ESH_KAPPEND ++killing; /* don't modify killing signal */ -#endif return value; } value = count; @@ -763,18 +697,14 @@ static int escape(Emacs_t* ep,genchar *out,int count) ep->mark = cur; return -1; -#ifdef ESH_KAPPEND case '+': /* M-+ = append next kill */ killing = 2; return -1; /* no argument for next command */ -#endif case 'p': /* M-p == ^W^Y (copy stack == kill & yank) */ ed_ungetchar(ep->ed,cntl('Y')); ed_ungetchar(ep->ed,cntl('W')); -#ifdef ESH_KAPPEND killing = 0; /* start fresh */ -#endif return -1; case 'l': /* M-l == lowercase */ @@ -824,9 +754,7 @@ static int escape(Emacs_t* ep,genchar *out,int count) if (i-cur) { ed_ungetchar(ep->ed,cntl('D')); -#ifdef ESH_KAPPEND ++killing; /* keep killing signal */ -#endif return i-cur; } beep(); @@ -854,16 +782,13 @@ static int escape(Emacs_t* ep,genchar *out,int count) else { ed_ungetchar(ep->ed,usrerase); -#ifdef ESH_KAPPEND ++killing; -#endif return cur-i; } } case '>': ed_ungetchar(ep->ed,cntl('N')); -#ifdef ESH_NFIRST if (ep->in_mult) { location.hist_command = histlines; @@ -874,22 +799,13 @@ static int escape(Emacs_t* ep,genchar *out,int count) location.hist_command = histlines - 1; location.hist_line = 0; } -#else - hline = histlines-1; - hloff = 0; -#endif /* ESH_NFIRST */ return 0; case '<': ed_ungetchar(ep->ed,cntl('P')); hloff = 0; -#ifdef ESH_NFIRST hline = hismin + 1; return 0; -#else - return hline-hismin; -#endif /* ESH_NFIRST */ - case '#': ed_ungetchar(ep->ed,'\n'); @@ -1183,11 +1099,7 @@ static int escape(Emacs_t* ep,genchar *out,int count) default: /* look for user defined macro definitions */ if(ed_macro(ep->ed,i)) -# ifdef ESH_BETTER return count; /* pass argument to macro */ -# else - return -1; -# endif /* ESH_BETTER */ beep(); /* FALLTHROUGH */ } @@ -1214,7 +1126,6 @@ static void xcommands(Emacs_t *ep,int count) draw(ep,UPDATE); return; -#ifdef ESH_BETTER case cntl('E'): /* invoke emacs on current command */ if(eol>=0 && sh.hist_ptr) { @@ -1258,58 +1169,56 @@ static void xcommands(Emacs_t *ep,int count) } return; -# define itos(i) fmtint(i,0) /* want signed conversion */ - case cntl('H'): /* ^X^H show history info */ { char hbuf[MAXLINE]; strcpy(hbuf, "Current command "); - strcat(hbuf, itos(hline)); + strcat(hbuf, fmtint(hline,0)); if (hloff) { strcat(hbuf, " (line "); - strcat(hbuf, itos(hloff+1)); + strcat(hbuf, fmtint(hloff+1,0)); strcat(hbuf, ")"); } if ((hline != location.hist_command) || (hloff != location.hist_line)) { strcat(hbuf, "; Previous command "); - strcat(hbuf, itos(location.hist_command)); + strcat(hbuf, fmtint(location.hist_command,0)); if (location.hist_line) { strcat(hbuf, " (line "); - strcat(hbuf, itos(location.hist_line+1)); + strcat(hbuf, fmtint(location.hist_line+1,0)); strcat(hbuf, ")"); } } show_info(ep,hbuf); return; } -# if !_AST_release /* debugging, modify as required */ + +#if !_AST_release /* debugging, modify as required */ case cntl('D'): /* ^X^D show debugging info */ { char debugbuf[MAXLINE]; strcpy(debugbuf, "count="); - strcat(debugbuf, itos(count)); + strcat(debugbuf, fmtint(count,0)); strcat(debugbuf, " eol="); - strcat(debugbuf, itos(eol)); + strcat(debugbuf, fmtint(eol,0)); strcat(debugbuf, " cur="); - strcat(debugbuf, itos(cur)); + strcat(debugbuf, fmtint(cur,0)); strcat(debugbuf, " crallowed="); - strcat(debugbuf, itos(crallowed)); + strcat(debugbuf, fmtint(crallowed,0)); strcat(debugbuf, " plen="); - strcat(debugbuf, itos(plen)); + strcat(debugbuf, fmtint(plen,0)); strcat(debugbuf, " w_size="); - strcat(debugbuf, itos(w_size)); + strcat(debugbuf, fmtint(w_size,0)); show_info(ep,debugbuf); return; } -# endif /* debugging code */ -#endif /* ESH_BETTER */ +#endif /* debugging code */ default: beep(); @@ -1363,9 +1272,6 @@ static int dosearch(Emacs_t *ep, genchar *out, int direction) static void search(Emacs_t* ep,genchar *out,int direction) { -#ifndef ESH_NFIRST - Histloc_t location; -#endif int i,sl; genchar str_buff[LBUF]; genchar *string = drawbuff; @@ -1459,11 +1365,7 @@ static void search(Emacs_t* ep,genchar *out,int direction) if(i>0) { hline = i; -#ifdef ESH_NFIRST hloff = location.hist_line = 0; /* display first line of multi line command */ -#else - hloff = location.hist_line; -#endif /* ESH_NFIRST */ hist_copy((char*)out,MAXLINE, hline,hloff); #if SHOPT_MULTIBYTE ed_internal((char*)out,out); @@ -1473,13 +1375,8 @@ static void search(Emacs_t* ep,genchar *out,int direction) if (i < 0) { beep(); -#ifdef ESH_NFIRST location.hist_command = hline; location.hist_line = hloff; -#else - hloff = 0; - hline = histlines; -#endif /* ESH_NFIRST */ } restore: genncpy(string,str_buff,sizeof(str_buff)/sizeof(*str_buff)); diff --git a/src/cmd/ksh93/edit/hexpand.c b/src/cmd/ksh93/edit/hexpand.c index 973d3be93174..1b806a699112 100644 --- a/src/cmd/ksh93/edit/hexpand.c +++ b/src/cmd/ksh93/edit/hexpand.c @@ -10,6 +10,7 @@ * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html * * (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) * * * +* Karsten Fleischer * * David Korn * * Martijn Dekker * * Johnothan King * diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index d3db42e05ede..e24dfd3b2832 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -10,6 +10,7 @@ * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html * * (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) * * * +* P.D. Sullivan * * David Korn * * Martijn Dekker * * Johnothan King * @@ -1688,14 +1689,13 @@ static void refresh(Vi_t* vp, int mode) { int p; int v; + int w; int first_w = vp->first_wind; int p_differ; int new_lw; int ncur_phys; int opflag; /* search optimize flag */ -# define w v - /*** find out if it's necessary to start translating at beginning ***/ if(lookahead>0) @@ -1844,7 +1844,6 @@ static void refresh(Vi_t* vp, int mode) cursor(vp,ncur_phys); ed_flush(vp->ed); return; -# undef w } /*{ REPLACE( char, increment ) diff --git a/src/cmd/ksh93/sh.1 b/src/cmd/ksh93/sh.1 index 758929f1306f..0b1cf3ab93e0 100644 --- a/src/cmd/ksh93/sh.1 +++ b/src/cmd/ksh93/sh.1 @@ -5350,7 +5350,9 @@ command, usually Kill the entire current line. .TP 10 .BI ^Y -Restore last item removed from line. (Yank item back to the line.) +Yank (undelete, paste): restore the text deleted by the last sequence +of one or more kill or delete commands. +Deleted text may be restored multiple times by repeating the command. .TP 10 .BI ^X^E Edit the current command line in a full editor (as set in the @@ -5364,6 +5366,10 @@ variable, or in that order of preference). The command line is executed if the file is saved before exiting the editor. .TP 10 +.BI ^X^H +Show the current history position and, if available, the saved history +position from the previous command line (which ^N will start from). +.TP 10 .BI ^L Line feed and print current line. .TP 10 @@ -5393,7 +5399,7 @@ if the current line is empty. Fetch previous command. Each time .B ^P -is entered +is entered, the previous command back in time is accessed. Moves back one line when not on the first line of a multi-line command. .TP 10 @@ -5427,8 +5433,13 @@ Fetch the most recent (youngest) history line. Fetch next command line. Each time .B ^N -is entered +is entered, the next command line forward in time is accessed. +If +.B ^N +is entered as the first history-related command after +the prompt, it will access the next command relative to +the previous command line's last known history position. .TP 10 .BI M-[6~ (Page down) @@ -5477,8 +5488,10 @@ the next line relative to current line from the history file. .TP 10 .BI M- digits -(Escape) Define numeric parameter, the digits +(Escape) Define a numeric parameter. The digits are taken as a parameter to the next command. +Except where otherwise specified, +the parameter indicates the amount of times the command will be repeated. The commands that accept a parameter are .BR ^F , .BR ^B , @@ -5513,6 +5526,7 @@ value will be inserted on the input queue. The .I letter must not be one of the above meta-functions. +Any numeric parameter is passed on to the command substituted. .TP 10 .BI M-[ letter Soft-key \- Your alias list is searched for an @@ -5520,7 +5534,8 @@ alias by the name .BI _\&_ letter and if an alias of this name is defined, its value will be inserted on the input queue. -This can be used to program function keys on many terminals. +This can be used to program function keys on some terminals. +Any numeric parameter is passed on to the command substituted. .TP 10 .B M-. The last word of the previous command is inserted diff --git a/src/cmd/ksh93/sh/arith.c b/src/cmd/ksh93/sh/arith.c index 70931773424d..b16f6aad74e6 100644 --- a/src/cmd/ksh93/sh/arith.c +++ b/src/cmd/ksh93/sh/arith.c @@ -14,6 +14,7 @@ * Martijn Dekker * * Johnothan King * * hyenias <58673227+hyenias@users.noreply.github.com> * +* dnewhall * * * ***********************************************************************/ /* diff --git a/src/cmd/ksh93/tests/_common b/src/cmd/ksh93/tests/_common index 6f90b410a64c..e4a0f0bf345c 100644 --- a/src/cmd/ksh93/tests/_common +++ b/src/cmd/ksh93/tests/_common @@ -1,7 +1,7 @@ ######################################################################## # # # This file is part of the ksh 93u+m package # -# Copyright (c) 1982-2012 AT&T Intellectual Property # +# Copyright (c) 1995-2012 AT&T Intellectual Property # # Copyright (c) 2021-2024 Contributors to ksh 93u+m # # and is licensed under the # # Eclipse Public License, Version 2.0 # diff --git a/src/cmd/ksh93/tests/libcmd.sh b/src/cmd/ksh93/tests/libcmd.sh index 11c253fcdb80..62138642645a 100755 --- a/src/cmd/ksh93/tests/libcmd.sh +++ b/src/cmd/ksh93/tests/libcmd.sh @@ -14,6 +14,7 @@ # Kurtis Rader # # Johnothan King # # Martijn Dekker # +# dnewhall # # # ######################################################################## diff --git a/src/cmd/ksh93/tests/shtests b/src/cmd/ksh93/tests/shtests index 942a026022be..e8b38a3d7a3f 100755 --- a/src/cmd/ksh93/tests/shtests +++ b/src/cmd/ksh93/tests/shtests @@ -1,3 +1,23 @@ +######################################################################## +# # +# This software is part of the ast package # +# Copyright (c) 1995-2012 AT&T Intellectual Property # +# Copyright (c) 2020-2024 Contributors to ksh 93u+m # +# and is licensed under the # +# Eclipse Public License, Version 2.0 # +# # +# A copy of the License is available at # +# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html # +# (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) # +# # +# David Korn # +# Glenn Fowler # +# Martijn Dekker # +# Johnothan King # +# Phi # +# # +######################################################################## + : ksh regression test harness : command=shtests @@ -49,7 +69,7 @@ USAGE=$' [ test.sh ... ] [ name=value ... ] -[+SEE ALSO?\bksh\b(1), \bregress\b(1), \brt\b(1)] +[+SEE ALSO?\bksh\b(1), \bregress\b(1)] ' function usage diff --git a/src/lib/libcmd/basename.c b/src/lib/libcmd/basename.c index 1430cb55f732..5e3d335d4668 100644 --- a/src/lib/libcmd/basename.c +++ b/src/lib/libcmd/basename.c @@ -14,6 +14,7 @@ * David Korn * * Martijn Dekker * * Johnothan King * +* dnewhall * * * ***********************************************************************/ /* diff --git a/src/lib/libcmd/dirname.c b/src/lib/libcmd/dirname.c index dabede970474..d02214c23fbe 100644 --- a/src/lib/libcmd/dirname.c +++ b/src/lib/libcmd/dirname.c @@ -14,6 +14,7 @@ * David Korn * * Martijn Dekker * * Johnothan King * +* dnewhall * * * ***********************************************************************/ /*