CVS commit: src/bin/ksh

2022-08-21 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Aug 21 20:12:37 UTC 2022

Modified Files:
src/bin/ksh: ksh.Man

Log Message:
ksh(1): fix pasto in the description of the -l option.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/bin/ksh/ksh.Man

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/ksh.Man
diff -u src/bin/ksh/ksh.Man:1.28 src/bin/ksh/ksh.Man:1.29
--- src/bin/ksh/ksh.Man:1.28	Sun Aug  7 11:06:18 2022
+++ src/bin/ksh/ksh.Man	Sun Aug 21 20:12:37 2022
@@ -1,5 +1,5 @@
 '\" t
-.\" $NetBSD: ksh.Man,v 1.28 2022/08/07 11:06:18 andvar Exp $
+.\" $NetBSD: ksh.Man,v 1.29 2022/08/21 20:12:37 uwe Exp $
 .\"{{{}}}
 .\"{{{  Notes about man page
 .\" - use the pseudo-macros .sh( and .sh) to begin and end sh-specific
@@ -66,7 +66,6 @@ the shell executes the command(s) contai
 interactive mode \(em see below
 .IP \fB\-l\fP
 login shell \(em see below
-interactive mode \(em see below
 .IP \fB\-s\fP
 the shell reads commands from standard input; all non-option arguments
 are positional parameters



CVS commit: src/bin/ksh

2022-08-21 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Aug 21 20:12:37 UTC 2022

Modified Files:
src/bin/ksh: ksh.Man

Log Message:
ksh(1): fix pasto in the description of the -l option.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/bin/ksh/ksh.Man

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/ksh

2022-07-03 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Jul  3 06:30:31 UTC 2022

Modified Files:
src/bin/ksh: expr.c

Log Message:
Fix core dump caused by
ksh -c '(i=10; echo $((++-+++i)))'
reported by Steffen Nurpmeso (not on a NetBSD list or PR).

Seems pointless to fix just one of the bugs in this thing, but this one was
easy enough (and stupid enough).   (The "i=10" part is unimportant, as is the 
sub-shell).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/expr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/expr.c
diff -u src/bin/ksh/expr.c:1.12 src/bin/ksh/expr.c:1.13
--- src/bin/ksh/expr.c:1.12	Tue May  8 16:37:59 2018
+++ src/bin/ksh/expr.c	Sun Jul  3 06:30:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr.c,v 1.12 2018/05/08 16:37:59 kamil Exp $	*/
+/*	$NetBSD: expr.c,v 1.13 2022/07/03 06:30:31 kre Exp $	*/
 
 /*
  * Korn expression evaluation
@@ -9,7 +9,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: expr.c,v 1.12 2018/05/08 16:37:59 kamil Exp $");
+__RCSID("$NetBSD: expr.c,v 1.13 2022/07/03 06:30:31 kre Exp $");
 #endif
 
 
@@ -311,6 +311,8 @@ evalexpr(es, prec)
 			token(es);
 		} else if (op == O_PLUSPLUS || op == O_MINUSMINUS) {
 			token(es);
+			if (es->tok != VAR)
+evalerr(es, ET_LVALUE, opinfo[(int) op].name);
 			vl = do_ppmm(es, op, es->val, true);
 			token(es);
 		} else if (op == VAR || op == LIT) {



CVS commit: src/bin/ksh

2022-07-03 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Jul  3 06:30:31 UTC 2022

Modified Files:
src/bin/ksh: expr.c

Log Message:
Fix core dump caused by
ksh -c '(i=10; echo $((++-+++i)))'
reported by Steffen Nurpmeso (not on a NetBSD list or PR).

Seems pointless to fix just one of the bugs in this thing, but this one was
easy enough (and stupid enough).   (The "i=10" part is unimportant, as is the 
sub-shell).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/expr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/ksh

2021-09-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 16 19:44:01 UTC 2021

Modified Files:
src/bin/ksh: c_test.c shf.c tree.c vi.c

Log Message:
It is either teaching gcc about aaah or adding FALLTHROUGH.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/bin/ksh/c_test.c src/bin/ksh/tree.c
cvs rdiff -u -r1.13 -r1.14 src/bin/ksh/shf.c
cvs rdiff -u -r1.20 -r1.21 src/bin/ksh/vi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/c_test.c
diff -u src/bin/ksh/c_test.c:1.9 src/bin/ksh/c_test.c:1.10
--- src/bin/ksh/c_test.c:1.9	Fri Jun 30 00:41:19 2017
+++ src/bin/ksh/c_test.c	Thu Sep 16 15:44:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: c_test.c,v 1.9 2017/06/30 04:41:19 kamil Exp $	*/
+/*	$NetBSD: c_test.c,v 1.10 2021/09/16 19:44:01 christos Exp $	*/
 
 /*
  * test(1); version 7-like  --  author Erik Baalbergen
@@ -11,7 +11,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: c_test.c,v 1.9 2017/06/30 04:41:19 kamil Exp $");
+__RCSID("$NetBSD: c_test.c,v 1.10 2021/09/16 19:44:01 christos Exp $");
 #endif
 
 #include 
@@ -393,6 +393,7 @@ test_eval(te, op, opnd1, opnd2, do_eval)
 return v1 < v2;
 			}
 		}
+		abort();
 	  case TO_FILNT: /* -nt */
 		{
 			int s2;
Index: src/bin/ksh/tree.c
diff -u src/bin/ksh/tree.c:1.9 src/bin/ksh/tree.c:1.10
--- src/bin/ksh/tree.c:1.9	Tue May  8 12:37:59 2018
+++ src/bin/ksh/tree.c	Thu Sep 16 15:44:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.9 2018/05/08 16:37:59 kamil Exp $	*/
+/*	$NetBSD: tree.c,v 1.10 2021/09/16 19:44:01 christos Exp $	*/
 
 /*
  * command tree climbing
@@ -6,7 +6,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: tree.c,v 1.9 2018/05/08 16:37:59 kamil Exp $");
+__RCSID("$NetBSD: tree.c,v 1.10 2021/09/16 19:44:01 christos Exp $");
 #endif
 
 
@@ -106,8 +106,8 @@ ptree(t, indent, shf)
 #ifdef KSH
 	  case TSELECT:
 		fptreef(shf, indent, "select %s ", t->str);
-		/* fall through */
 #endif /* KSH */
+		/*FALLTHROUGH*/
 	  case TFOR:
 		if (t->type == TFOR)
 			fptreef(shf, indent, "for %s ", t->str);

Index: src/bin/ksh/shf.c
diff -u src/bin/ksh/shf.c:1.13 src/bin/ksh/shf.c:1.14
--- src/bin/ksh/shf.c:1.13	Thu Jun 29 23:56:12 2017
+++ src/bin/ksh/shf.c	Thu Sep 16 15:44:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: shf.c,v 1.13 2017/06/30 03:56:12 kamil Exp $	*/
+/*	$NetBSD: shf.c,v 1.14 2021/09/16 19:44:01 christos Exp $	*/
 
 /*
  *  Shell file I/O routines
@@ -6,7 +6,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: shf.c,v 1.13 2017/06/30 03:56:12 kamil Exp $");
+__RCSID("$NetBSD: shf.c,v 1.14 2021/09/16 19:44:01 christos Exp $");
 #endif
 
 #include 
@@ -984,6 +984,7 @@ shf_vfprintf(shf, fmt, args)
 			if (sizeof(char *) > sizeof(int))
 flags |= FL_LONG; /* hope it fits.. */
 			/* aaahhh... */
+			/*FALLTHROUGH*/
 		case 'd':
 		case 'i':
 		case 'o':
@@ -1000,7 +1001,7 @@ shf_vfprintf(shf, fmt, args)
 else
 	tmp = 0;
 /* aaa. */
-
+/*FALLTHROUGH*/
 			case 'u':
 do {
 	*--s = lnum % 10 + '0';

Index: src/bin/ksh/vi.c
diff -u src/bin/ksh/vi.c:1.20 src/bin/ksh/vi.c:1.21
--- src/bin/ksh/vi.c:1.20	Tue May  8 12:37:59 2018
+++ src/bin/ksh/vi.c	Thu Sep 16 15:44:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vi.c,v 1.20 2018/05/08 16:37:59 kamil Exp $	*/
+/*	$NetBSD: vi.c,v 1.21 2021/09/16 19:44:01 christos Exp $	*/
 
 /*
  *	vi command editing
@@ -9,7 +9,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: vi.c,v 1.20 2018/05/08 16:37:59 kamil Exp $");
+__RCSID("$NetBSD: vi.c,v 1.21 2021/09/16 19:44:01 christos Exp $");
 #endif
 
 #include "config.h"
@@ -793,6 +793,7 @@ vi_cmd(argcnt, cmd)
 		case 'Y':
 			cmd = "y$";
 			/* ahh... */
+			/*FALLTHROUGH*/
 		case 'c':
 		case 'd':
 		case 'y':
@@ -1004,6 +1005,7 @@ vi_cmd(argcnt, cmd)
 			if (hnum == hlast)
 hnum = -1;
 			/* ahhh */
+			/*FALLTHROUGH*/
 		case '/':
 			c3 = 1;
 			srchlen = 0;
@@ -1131,6 +1133,7 @@ vi_cmd(argcnt, cmd)
 		case Ctrl('['):			/* some annoying at ksh's */
 			if (!Flag(FVIESCCOMPLETE))
 return -1;
+			/*FALLTHROUGH*/
 		case '\\':			/* at ksh */
 		case Ctrl('f'):			/* Nonstandard vi/ksh */
 			complete_word(1, argcnt);
@@ -1194,7 +1197,7 @@ domove(argcnt, cmd, sub)
 		fsavecmd = *cmd;
 		fsavech = cmd[1];
 		/* drop through */
-
+		/*FALLTHROUGH*/
 	case ',':
 	case ';':
 		if (fsavecmd == ' ')



CVS commit: src/bin/ksh

2021-09-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 16 19:44:01 UTC 2021

Modified Files:
src/bin/ksh: c_test.c shf.c tree.c vi.c

Log Message:
It is either teaching gcc about aaah or adding FALLTHROUGH.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/bin/ksh/c_test.c src/bin/ksh/tree.c
cvs rdiff -u -r1.13 -r1.14 src/bin/ksh/shf.c
cvs rdiff -u -r1.20 -r1.21 src/bin/ksh/vi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/ksh

2021-09-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 16 19:43:33 UTC 2021

Modified Files:
src/bin/ksh: c_ksh.c

Log Message:
support -Z


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/bin/ksh/c_ksh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/c_ksh.c
diff -u src/bin/ksh/c_ksh.c:1.29 src/bin/ksh/c_ksh.c:1.30
--- src/bin/ksh/c_ksh.c:1.29	Sun Jun  3 08:18:29 2018
+++ src/bin/ksh/c_ksh.c	Thu Sep 16 15:43:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: c_ksh.c,v 1.29 2018/06/03 12:18:29 kamil Exp $	*/
+/*	$NetBSD: c_ksh.c,v 1.30 2021/09/16 19:43:33 christos Exp $	*/
 
 /*
  * built-in Korn commands: c_*
@@ -6,7 +6,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: c_ksh.c,v 1.29 2018/06/03 12:18:29 kamil Exp $");
+__RCSID("$NetBSD: c_ksh.c,v 1.30 2021/09/16 19:43:33 christos Exp $");
 #endif
 
 #include 
@@ -1072,9 +1072,10 @@ c_jobs(wp)
 	int optc;
 	int flag = 0;
 	int nflag = 0;
+	int Zflag = 0;
 	int rv = 0;
 
-	while ((optc = ksh_getopt(wp, _opt, "lpnz")) != EOF)
+	while ((optc = ksh_getopt(wp, _opt, "lpnzZ")) != EOF)
 		switch (optc) {
 		  case 'l':
 			flag = 1;
@@ -1088,10 +1089,21 @@ c_jobs(wp)
 		  case 'z':	/* debugging: print zombies */
 			nflag = -1;
 			break;
+		  case 'Z':
+			Zflag = 1;
+			break;
 		  case '?':
 			return 1;
 		}
 	wp += builtin_opt.optind;
+	if (Zflag) {
+		if (*wp && **wp) {
+			setproctitle("%s", *wp);
+		} else {
+			setproctitle(NULL);
+		}
+		return 0;
+	}
 	if (!*wp) {
 		if (j_jobs((char *) 0, flag, nflag))
 			rv = 1;



CVS commit: src/bin/ksh

2021-09-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 16 19:43:33 UTC 2021

Modified Files:
src/bin/ksh: c_ksh.c

Log Message:
support -Z


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/bin/ksh/c_ksh.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/ksh

2019-10-29 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Oct 29 16:19:59 UTC 2019

Modified Files:
src/bin/ksh: misc.c

Log Message:
Avoid arithmetics on strings.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/bin/ksh/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/ksh

2019-10-29 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Oct 29 16:19:59 UTC 2019

Modified Files:
src/bin/ksh: misc.c

Log Message:
Avoid arithmetics on strings.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/bin/ksh/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/misc.c
diff -u src/bin/ksh/misc.c:1.24 src/bin/ksh/misc.c:1.25
--- src/bin/ksh/misc.c:1.24	Tue May  8 16:37:59 2018
+++ src/bin/ksh/misc.c	Tue Oct 29 16:19:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.24 2018/05/08 16:37:59 kamil Exp $	*/
+/*	$NetBSD: misc.c,v 1.25 2019/10/29 16:19:59 joerg Exp $	*/
 
 /*
  * Miscellaneous functions
@@ -6,7 +6,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: misc.c,v 1.24 2018/05/08 16:37:59 kamil Exp $");
+__RCSID("$NetBSD: misc.c,v 1.25 2019/10/29 16:19:59 joerg Exp $");
 #endif
 
 
@@ -1091,7 +1091,7 @@ print_value_quoted(s)
 	}
 	for (p = s; *p; p++) {
 		if (*p == '\'') {
-			shprintf("%s", "'\\'" + 1 - inquote);
+			shprintf("%s", &"'\\'"[1 - inquote]);
 			inquote = 0;
 		} else {
 			if (!inquote) {



CVS commit: src/bin/ksh

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 11:01:09 UTC 2019

Modified Files:
src/bin/ksh: eval.c lex.c

Log Message:
Fix FALLTHROUGH comments.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/bin/ksh/eval.c
cvs rdiff -u -r1.23 -r1.24 src/bin/ksh/lex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/eval.c
diff -u src/bin/ksh/eval.c:1.25 src/bin/ksh/eval.c:1.26
--- src/bin/ksh/eval.c:1.25	Tue Jun 12 14:13:55 2018
+++ src/bin/ksh/eval.c	Thu Sep 26 11:01:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.c,v 1.25 2018/06/12 14:13:55 kamil Exp $	*/
+/*	$NetBSD: eval.c,v 1.26 2019/09/26 11:01:09 mlelstv Exp $	*/
 
 /*
  * Expansion - quoting, separation, substitution, globbing
@@ -6,7 +6,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: eval.c,v 1.25 2018/06/12 14:13:55 kamil Exp $");
+__RCSID("$NetBSD: eval.c,v 1.26 2019/09/26 11:01:09 mlelstv Exp $");
 #endif
 
 #include 
@@ -493,6 +493,7 @@ expand(cp, wp, f)
 		  case XARGSEP:
 			type = XARG;
 			quote = 1;
+			/* FALLTHROUGH */
 		  case XARG:
 			if ((c = *x.str++) == '\0') {
 /* force null words to be created so

Index: src/bin/ksh/lex.c
diff -u src/bin/ksh/lex.c:1.23 src/bin/ksh/lex.c:1.24
--- src/bin/ksh/lex.c:1.23	Tue May  8 16:37:59 2018
+++ src/bin/ksh/lex.c	Thu Sep 26 11:01:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex.c,v 1.23 2018/05/08 16:37:59 kamil Exp $	*/
+/*	$NetBSD: lex.c,v 1.24 2019/09/26 11:01:09 mlelstv Exp $	*/
 
 /*
  * lexical analysis and source input
@@ -6,7 +6,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: lex.c,v 1.23 2018/05/08 16:37:59 kamil Exp $");
+__RCSID("$NetBSD: lex.c,v 1.24 2019/09/26 11:01:09 mlelstv Exp $");
 #endif
 
 
@@ -254,7 +254,7 @@ yylex(cf)
 		*wp++ = QCHAR, *wp++ = c;
 		break;
 	}
-	/* FALLTROUGH */
+	/* FALLTHROUGH */
   default:
 	Xcheck(ws, wp);
 	if (c) { /* trailing \ is lost */



CVS commit: src/bin/ksh

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 11:01:09 UTC 2019

Modified Files:
src/bin/ksh: eval.c lex.c

Log Message:
Fix FALLTHROUGH comments.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/bin/ksh/eval.c
cvs rdiff -u -r1.23 -r1.24 src/bin/ksh/lex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/bin/ksh

2018-06-12 Thread Valery Ushakov
On Tue, Jun 12, 2018 at 14:13:55 +, Kamil Rytarowski wrote:

> UBSan can detect that during switching a login to root there is unportable
> left shift operation:
> 
> $ su -
> Password:
> /public/src.git/bin/ksh/eval.c:598:13: runtime error: left shift of 
> 1073741824 by 1 places cannot be represented in type 'int'
> #

Is this, seriously, how you reproduce it?  It doesn't trigger on just
running ksh?  In which case what is the real problem here - it must be
triggered by some .profile code, which your "reproducer" doesn't
provide.

-uwe


Re: CVS commit: src/bin/ksh

2017-06-22 Thread Kamil Rytarowski
On 23.06.2017 02:12, matthew green wrote:
> "Kamil Rytarowski" writes:
>> Module Name: src
>> Committed By:kamil
>> Date:Thu Jun 22 13:32:04 UTC 2017
>>
>> Modified Files:
>>  src/bin/ksh: c_ksh.c edit.c path.c sh.h
>>
>> Log Message:
>> Remove ancient cygwin support in ksh(1)
>>
>> OK by 
> 
> i thought ksh was upstream owned code, so changes like this
> seem to be out of place in netbsd tree.
> 
> why are you doing all this?
> 
> 
> .mrg
> 

I haven't found active upstream development since around 1999; I have
local patches and I took maintainership. This is what happened in other
BSDs.

I got some old patches and I will try to upstream them after removing
K code. This will also help to address some local bugs that affect my
shell usage.

The domain for multiplatform legacy Unices is covered by MKSH (developed
against gcc1, gcc2). So no need to compete with them for this niche.



signature.asc
Description: OpenPGP digital signature


re: CVS commit: src/bin/ksh

2017-06-22 Thread matthew green
"Kamil Rytarowski" writes:
> Module Name:  src
> Committed By: kamil
> Date: Thu Jun 22 13:32:04 UTC 2017
> 
> Modified Files:
>   src/bin/ksh: c_ksh.c edit.c path.c sh.h
> 
> Log Message:
> Remove ancient cygwin support in ksh(1)
> 
> OK by 

i thought ksh was upstream owned code, so changes like this
seem to be out of place in netbsd tree.

why are you doing all this?


.mrg.