View | Details | Raw Unified | Return to bug 46317
Collapse All | Expand All

(-)oksh-7.0/README.md (-2 / +11 lines)
Lines 57-62 Link Here
57
* [CompCert](https://compcert.org/)
57
* [CompCert](https://compcert.org/)
58
* [Nils Weller's C compiler](http://nwcc.sourceforge.net/)
58
* [Nils Weller's C compiler](http://nwcc.sourceforge.net/)
59
* [cproc](https://sr.ht/~mcf/cproc/) (Currently requires a small tweak to ignore a volatile store error)
59
* [cproc](https://sr.ht/~mcf/cproc/) (Currently requires a small tweak to ignore a volatile store error)
60
* [vbcc](http://www.compilers.de/vbcc.html) (Only tested on OpenBSD/i386)
61
* [chibicc](https://github.com/rui314/chibicc)
60
62
61
Building with a compiler not listed here? Add it and send a pull request!
63
Building with a compiler not listed here? Add it and send a pull request!
62
64
Lines 88-93 Link Here
88
$ make && sudo make install
90
$ make && sudo make install
89
```
91
```
90
92
93
Out-of-tree builds
94
------------------
95
The `configure` script will detect out-of-tree builds if you prefer to
96
build out-of-tree. In order for this to work, the `VPATH` make extension
97
is used. While not POSIX, `VPATH` is known to work with BSD make and GNU
98
make. In-tree builds create a fully POSIX `Makefile`.
99
91
Cross compiling
100
Cross compiling
92
---------------
101
---------------
93
Cross compiling can be achieved by running `configure` as follows:
102
Cross compiling can be achieved by running `configure` as follows:
Lines 130-134 Link Here
130
139
131
Get a tarball
140
Get a tarball
132
-------------
141
-------------
133
See releases tab. The latest release is oksh-7.0, which matches the ksh(1)
142
See releases tab. The latest release is oksh-7.3, which matches the ksh(1)
134
from OpenBSD 7.0, released October 14, 2021.
143
from OpenBSD 7.3, released April 10, 2023.
(-)oksh-7.0/configure (-7 / +89 lines)
Lines 24-31 Link Here
24
EOF
24
EOF
25
fi
25
fi
26
26
27
if [ ! -z "$vpath" ] ; then
27
cat << EOF >> Makefile
28
cat << EOF >> Makefile
28
29
30
VPATH =		$vpath
31
EOF
32
fi
33
34
cat << EOF >> Makefile
35
29
PREFIX =	$prefix
36
PREFIX =	$prefix
30
BINDIR =	$bindir
37
BINDIR =	$bindir
31
MANDIR =	$mandir
38
MANDIR =	$mandir
Lines 119-124 Link Here
119
  fi
126
  fi
120
}
127
}
121
128
129
c11noreturncheck() {
130
  cat << EOF > conftest.c
131
#include <stdlib.h>
132
_Noreturn void usage(void){exit(1);}int main(void){usage();return 0;}
133
EOF
134
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
135
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
136
  if [ $? -eq 0 ] ; then
137
    rm -f conftest conftest.o conftest.c
138
    return 0
139
  else
140
    rm -f conftest conftest.o conftest.c
141
    return 1
142
  fi
143
}
144
122
c99check() {
145
c99check() {
123
  cat << EOF > conftest.c
146
  cat << EOF > conftest.c
124
#include <stdio.h>
147
#include <stdio.h>
Lines 274-280 Link Here
274
deadcheck() {
297
deadcheck() {
275
  cat << EOF > conftest.c
298
  cat << EOF > conftest.c
276
#include <stdlib.h>
299
#include <stdlib.h>
277
__dead usage(void){exit(1);}int main(void){usage();return 0;}
300
__dead void usage(void){exit(1);}int main(void){usage();return 0;}
278
EOF
301
EOF
279
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
302
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
280
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
303
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
Lines 290-296 Link Here
290
dead2check() {
313
dead2check() {
291
  cat << EOF > conftest.c
314
  cat << EOF > conftest.c
292
#include <stdlib.h>
315
#include <stdlib.h>
293
__dead2 usage(void){exit(1);}int main(void){usage();return 0;}
316
__dead2 void usage(void){exit(1);}int main(void){usage();return 0;}
294
EOF
317
EOF
295
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
318
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
296
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
319
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
Lines 431-437 Link Here
431
noreturncheck() {
454
noreturncheck() {
432
  cat << EOF > conftest.c
455
  cat << EOF > conftest.c
433
#include <stdlib.h>
456
#include <stdlib.h>
434
__attribute__((__noreturn__)) usage(void){exit(1);}int main(void){usage();return 0;}
457
__attribute__((__noreturn__)) void usage(void){exit(1);}int main(void){usage();return 0;}
435
EOF
458
EOF
436
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
459
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
437
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
460
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
Lines 487-493 Link Here
487
  cat << EOF > conftest.c
510
  cat << EOF > conftest.c
488
#include <sys/types.h>
511
#include <sys/types.h>
489
#include <unistd.h>
512
#include <unistd.h>
490
int main(void){setresgid(NULL, NULL, NULL);return 0;}
513
int main(void){setresgid(0, 0, 0);return 0;}
491
EOF
514
EOF
492
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
515
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
493
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
516
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
Lines 504-510 Link Here
504
  cat << EOF > conftest.c
527
  cat << EOF > conftest.c
505
#include <sys/types.h>
528
#include <sys/types.h>
506
#include <unistd.h>
529
#include <unistd.h>
507
int main(void){setresuid(NULL, NULL, NULL);return 0;}
530
int main(void){setresuid(0, 0, 0);return 0;}
508
EOF
531
EOF
509
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
532
  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
510
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
533
  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
Lines 781-786 Link Here
781
instsh=0
804
instsh=0
782
static=0
805
static=0
783
lto=0
806
lto=0
807
small=0
784
strip=1
808
strip=1
785
809
786
# Options
810
# Options
Lines 804-809 Link Here
804
	mandir=${opt#*=}
828
	mandir=${opt#*=}
805
	mandirset=1
829
	mandirset=1
806
	;;
830
	;;
831
    --cc=*)
832
	CC=${opt#*=}
833
	;;
834
    --cflags=*)
835
	CFLAGS=${opt#*=}
836
	;;
807
    --disable-curses|--enable-curses)
837
    --disable-curses|--enable-curses)
808
	if [ "x$opt" = "x--disable-curses" ] ; then
838
	if [ "x$opt" = "x--disable-curses" ] ; then
809
	  curses=0
839
	  curses=0
Lines 825-830 Link Here
825
	  instsh=0
855
	  instsh=0
826
	fi
856
	fi
827
	;;
857
	;;
858
    --disable-small|--enable-small)
859
	if [ "x$opt" = "x--enable-small" ] ; then
860
	  small=1
861
	  curses=0
862
	else
863
	  small=0
864
	fi
865
	;;
828
    --disable-static|--enable-static)
866
    --disable-static|--enable-static)
829
	if [ "x$opt" = "x--enable-static" ] ; then
867
	if [ "x$opt" = "x--enable-static" ] ; then
830
	  static=1
868
	  static=1
Lines 860-865 Link Here
860
	echo "Install executable to BINDIR [$bindir]"
898
	echo "Install executable to BINDIR [$bindir]"
861
	printf "  --mandir=MANDIR         "
899
	printf "  --mandir=MANDIR         "
862
	echo "Install manual pages to MANDIR [$mandir]"
900
	echo "Install manual pages to MANDIR [$mandir]"
901
	printf "  --cc=CC                 "
902
	echo "Use specified C compiler [default=cc]"
903
	printf "  --cflags=CFLAGS         "
904
        echo "Use specified CFLAGS [default=\"-g -O2\"]"
863
	printf "  --enable-curses         "
905
	printf "  --enable-curses         "
864
	echo "Use curses library for screen clear [default=yes]"
906
	echo "Use curses library for screen clear [default=yes]"
865
	printf "  --enable-ksh            "
907
	printf "  --enable-ksh            "
Lines 868-873 Link Here
868
	echo "Enable link-time optimization [default=no]"
910
	echo "Enable link-time optimization [default=no]"
869
	printf "  --enable-sh             "
911
	printf "  --enable-sh             "
870
	echo "Install additional sh executable [default=no]"
912
	echo "Install additional sh executable [default=no]"
913
	printf "  --enable-small          "
914
	echo "Disable curses and extended history [default=no]"
871
	printf "  --enable-static         "
915
	printf "  --enable-static         "
872
	echo "Statically link executables [default=no]"
916
	echo "Statically link executables [default=no]"
873
	printf "  --no-thanks             "
917
	printf "  --no-thanks             "
Lines 963-968 Link Here
963
  echo "$cc"
1007
  echo "$cc"
964
fi
1008
fi
965
1009
1010
if [ "x$cc" = "xvc" ] ; then
1011
  echo "using vbcc, setting CFLAGS to -g -O=990"
1012
  cflags="-g -O=990 -DEMACS -DVI"
1013
fi
1014
966
if [ "x$cflags" = "x-DEMACS -DVI" ] ; then
1015
if [ "x$cflags" = "x-DEMACS -DVI" ] ; then
967
  printf "checking if the compiler accepts -g -O2... "
1016
  printf "checking if the compiler accepts -g -O2... "
968
  defaultcflagscheck
1017
  defaultcflagscheck
Lines 1027-1035 Link Here
1027
	cflags="$cflags -D_ANSI_LIBRARY"
1076
	cflags="$cflags -D_ANSI_LIBRARY"
1028
	ldflags="$ldflags -Wl,-nopie"
1077
	ldflags="$ldflags -Wl,-nopie"
1029
	;;
1078
	;;
1079
      "xchibicc")
1080
	cflags="$cflags -D_ANSI_LIBRARY"
1081
	;;
1030
      "xnwcc")
1082
      "xnwcc")
1031
	ldflags="$ldflags -Wl,-nopie"
1083
	ldflags="$ldflags -Wl,-nopie"
1032
	;;
1084
	;;
1085
      "xvc")
1086
	cflags="$cflags -D_ANSI_LIBRARY"
1087
	;;
1033
    esac
1088
    esac
1034
    ;;
1089
    ;;
1035
  "xAIX"|"xOS400")
1090
  "xAIX"|"xOS400")
Lines 1052-1057 Link Here
1052
  fi
1107
  fi
1053
fi
1108
fi
1054
1109
1110
if [ $small -ne 0 ] ; then
1111
  cflags="$cflags -DSMALL"
1112
fi
1113
1055
cat << EOF > pconfig.h
1114
cat << EOF > pconfig.h
1056
/* This file automatically generated by configure.  */
1115
/* This file automatically generated by configure.  */
1057
1116
Lines 1076-1084 Link Here
1076
      echo "#define __dead __attribute__((__noreturn__))" >> pconfig.h
1135
      echo "#define __dead __attribute__((__noreturn__))" >> pconfig.h
1077
      echo "yes"
1136
      echo "yes"
1078
    else
1137
    else
1079
      echo "#define __dead" >> pconfig.h
1080
      echo "#define __attribute__(x)" >> pconfig.h
1081
      echo "no"
1138
      echo "no"
1139
      printf "checking for _Noreturn... "
1140
      c11noreturncheck
1141
      if [ $? -eq 0 ] ; then
1142
	echo "#ifdef __dead" >> pconfig.h
1143
	echo "#undef __dead" >> pconfig.h
1144
	echo "#endif" >> pconfig.h
1145
	echo "#define __dead _Noreturn" >> pconfig.h
1146
	echo "#define __attribute__(x)" >> pconfig.h
1147
	echo "yes"
1148
      else
1149
	echo "#define __dead" >> pconfig.h
1150
	echo "#define __attribute__(x)" >> pconfig.h
1151
	echo "no"
1152
      fi
1082
    fi
1153
    fi
1083
  fi
1154
  fi
1084
fi
1155
fi
Lines 1334-1339 Link Here
1334
  echo "yes"
1405
  echo "yes"
1335
else
1406
else
1336
  echo "no"
1407
  echo "no"
1408
fi
1409
1410
printf "checking for out-of-tree build... "
1411
if [ "x$(dirname $0)" = "x." ] ; then
1412
  echo "no"
1413
elif [ "x$(dirname $0)" = "x$(pwd)" ] ; then
1414
  echo "no"
1415
else
1416
  echo "yes"
1417
  vpath="$(dirname $0)"
1418
  cflags="$cflags -I$(pwd)"
1337
fi
1419
fi
1338
1420
1339
printf "creating Makefile... "
1421
printf "creating Makefile... "
(-)oksh-7.0/confstr.c (-1 / +1 lines)
Lines 28-34 Link Here
28
 * SUCH DAMAGE.
28
 * SUCH DAMAGE.
29
 */
29
 */
30
30
31
#include "portable.h"
31
#include "pconfig.h"
32
32
33
#ifndef HAVE_CONFSTR
33
#ifndef HAVE_CONFSTR
34
34
(-)oksh-7.0/emacs.c (-3 / +3 lines)
Lines 1-4 Link Here
1
/*	$OpenBSD: emacs.c,v 1.88 2021/06/27 15:53:33 schwarze Exp $	*/
1
/*	$OpenBSD: emacs.c,v 1.89 2021/10/09 21:38:00 halex Exp $	*/
2
2
3
/*
3
/*
4
 *  Emacs-like command line editing and history
4
 *  Emacs-like command line editing and history
Lines 277-283 Link Here
277
	{ 0, 0, 0 },
277
	{ 0, 0, 0 },
278
};
278
};
279
279
280
int
280
static int
281
isu8cont(unsigned char c)
281
isu8cont(unsigned char c)
282
{
282
{
283
	return (c & (0x80 | 0x40)) == 0x80;
283
	return (c & (0x80 | 0x40)) == 0x80;
Lines 905-911 Link Here
905
		if ((c = x_e_getc()) < 0)
905
		if ((c = x_e_getc()) < 0)
906
			return KSTD;
906
			return KSTD;
907
		f = kb_find_hist_func(c);
907
		f = kb_find_hist_func(c);
908
		if (c == CTRL('[')) {
908
		if (c == CTRL('[') || c == CTRL('@')) {
909
			x_e_ungetc(c);
909
			x_e_ungetc(c);
910
			break;
910
			break;
911
		} else if (f == x_search_hist)
911
		} else if (f == x_search_hist)
(-)oksh-7.0/exec.c (-4 / +6 lines)
Lines 1-4 Link Here
1
/*	$OpenBSD: exec.c,v 1.74 2019/06/28 13:34:59 deraadt Exp $	*/
1
/*	$OpenBSD: exec.c,v 1.76 2022/10/10 14:57:48 kn Exp $	*/
2
2
3
/*
3
/*
4
 * execute command tree
4
 * execute command tree
Lines 114-123 Link Here
114
		for (iowp = t->ioact; *iowp != NULL; iowp++) {
114
		for (iowp = t->ioact; *iowp != NULL; iowp++) {
115
			if (iosetup(*iowp, tp) < 0) {
115
			if (iosetup(*iowp, tp) < 0) {
116
				exstat = rv = 1;
116
				exstat = rv = 1;
117
				/* Redirection failures for special commands
117
				/* Except in the permanent case (exec 2>afile),
118
				 * redirection failures for special commands
118
				 * cause (non-interactive) shell to exit.
119
				 * cause (non-interactive) shell to exit.
119
				 */
120
				 */
120
				if (tp && tp->type == CSHELL &&
121
				if (tp && tp->val.f != c_exec &&
122
				    tp->type == CSHELL &&
121
				    (tp->flag & SPEC_BI))
123
				    (tp->flag & SPEC_BI))
122
					errorf(NULL);
124
					errorf(NULL);
123
				/* Deal with FERREXIT, quitenv(), etc. */
125
				/* Deal with FERREXIT, quitenv(), etc. */
Lines 1197-1203 Link Here
1197
	 * doesn't get removed too soon).
1199
	 * doesn't get removed too soon).
1198
	 */
1200
	 */
1199
	h = maketemp(ATEMP, TT_HEREDOC_EXP, &genv->temps);
1201
	h = maketemp(ATEMP, TT_HEREDOC_EXP, &genv->temps);
1200
	if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY, 0)) == -1) {
1202
	if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY)) == -1) {
1201
		warningf(true, "can't %s temporary file %s: %s",
1203
		warningf(true, "can't %s temporary file %s: %s",
1202
		    !shf ? "create" : "open",
1204
		    !shf ? "create" : "open",
1203
		    h->name, strerror(errno));
1205
		    h->name, strerror(errno));
(-)oksh-7.0/ksh.1 (-16 / +9 lines)
Lines 1-8 Link Here
1
.\"	$OpenBSD: ksh.1,v 1.215 2021/05/04 21:03:30 naddy Exp $
1
.\"	$OpenBSD: ksh.1,v 1.218 2022/12/26 17:45:27 jmc Exp $
2
.\"
2
.\"
3
.\"	Public Domain
3
.\"	Public Domain
4
.\"
4
.\"
5
.Dd $Mdocdate: May 4 2021 $
5
.Dd $Mdocdate: December 26 2022 $
6
.Dt KSH 1
6
.Dt KSH 1
7
.Os
7
.Os
8
.Sh NAME
8
.Sh NAME
Lines 745-753 Link Here
745
must be unquoted.
745
must be unquoted.
746
.It
746
.It
747
The second operand of the
747
The second operand of the
748
.Sq !=
748
.Sq = ,
749
.Sq ==
749
and
750
and
750
.Sq =
751
.Sq !=
751
expressions are patterns (e.g. the comparison
752
expressions are patterns (e.g. the comparison
752
.Ic [[ foobar = f*r ]]
753
.Ic [[ foobar = f*r ]]
753
succeeds).
754
succeeds).
Lines 2712-2720 Link Here
2712
.Cm +-x Oc
2713
.Cm +-x Oc
2713
.Op Fl p
2714
.Op Fl p
2714
.Op Cm +
2715
.Op Cm +
2715
.Oo Ar name
2716
.Op Ar name Ns Oo = Ns Ar value Oc Ar ...
2716
.Op Ns = Ns Ar value
2717
.Ar ... Oc
2718
.Xc
2717
.Xc
2719
Without arguments,
2718
Without arguments,
2720
.Ic alias
2719
.Ic alias
Lines 3453-3461 Link Here
3453
.It Xo
3452
.It Xo
3454
.Ic readonly
3453
.Ic readonly
3455
.Op Fl p
3454
.Op Fl p
3456
.Oo Ar parameter
3455
.Op Ar parameter Ns Oo = Ns Ar value Oc Ar ...
3457
.Op Ns = Ns Ar value
3458
.Ar ... Oc
3459
.Xc
3456
.Xc
3460
Sets the read-only attribute of the named parameters.
3457
Sets the read-only attribute of the named parameters.
3461
If values are given,
3458
If values are given,
Lines 4012-4018 Link Here
4012
.Pp
4009
.Pp
4013
If the
4010
If the
4014
.Fl p
4011
.Fl p
4015
option is given the output is slightly longer:
4012
option is given, the output is slightly longer:
4016
.Bd -literal -offset indent
4013
.Bd -literal -offset indent
4017
real     0.00
4014
real     0.00
4018
user     0.00
4015
user     0.00
Lines 4124-4134 Link Here
4124
.Op Fl i Ns Op Ar n
4121
.Op Fl i Ns Op Ar n
4125
.No \&| Fl f Op Fl tux
4122
.No \&| Fl f Op Fl tux
4126
.Oc
4123
.Oc
4127
.Oo
4124
.Op Ar name Ns Oo = Ns Ar value Oc Ar ...
4128
.Ar name
4129
.Op Ns = Ns Ar value
4130
.Ar ...
4131
.Oc
4132
.Xc
4125
.Xc
4133
Display or set parameter attributes.
4126
Display or set parameter attributes.
4134
With no
4127
With no
(-)oksh-7.0/lex.c (-1 / +3 lines)
Lines 1-4 Link Here
1
/*	$OpenBSD: lex.c,v 1.78 2018/01/15 14:58:05 jca Exp $	*/
1
/*	$OpenBSD: lex.c,v 1.79 2023/02/08 17:22:10 kn Exp $	*/
2
2
3
/*
3
/*
4
 * lexical analysis and source input
4
 * lexical analysis and source input
Lines 1335-1340 Link Here
1335
			case 'u':	/* '\' 'u' username */
1335
			case 'u':	/* '\' 'u' username */
1336
				strlcpy(strbuf, username, sizeof strbuf);
1336
				strlcpy(strbuf, username, sizeof strbuf);
1337
				break;
1337
				break;
1338
#ifndef SMALL
1338
			case 'v':	/* '\' 'v' version (short) */
1339
			case 'v':	/* '\' 'v' version (short) */
1339
				p = strchr(ksh_version, ' ');
1340
				p = strchr(ksh_version, ' ');
1340
				if (p)
1341
				if (p)
Lines 1350-1355 Link Here
1350
			case 'V':	/* '\' 'V' version (long) */
1351
			case 'V':	/* '\' 'V' version (long) */
1351
				strlcpy(strbuf, ksh_version, sizeof strbuf);
1352
				strlcpy(strbuf, ksh_version, sizeof strbuf);
1352
				break;
1353
				break;
1354
#endif /* SMALL */
1353
			case 'w':	/* '\' 'w' cwd */
1355
			case 'w':	/* '\' 'w' cwd */
1354
				p = str_val(global("PWD"));
1356
				p = str_val(global("PWD"));
1355
				n = strlen(str_val(global("HOME")));
1357
				n = strlen(str_val(global("HOME")));
(-)oksh-7.0/main.c (-2 / +10 lines)
Lines 1-4 Link Here
1
/*	$OpenBSD: main.c,v 1.98 2019/06/28 13:34:59 deraadt Exp $	*/
1
/*	$OpenBSD: main.c,v 1.99 2023/02/08 17:22:10 kn Exp $	*/
2
2
3
/*
3
/*
4
 * startup, main loop, environments and error handling
4
 * startup, main loop, environments and error handling
Lines 81-88 Link Here
81
static const char initsubs[] = "${PS2=> } ${PS3=#? } ${PS4=+ }";
81
static const char initsubs[] = "${PS2=> } ${PS3=#? } ${PS4=+ }";
82
82
83
static const char *initcoms [] = {
83
static const char *initcoms [] = {
84
#ifndef SMALL
84
	"typeset", "-r", "KSH_VERSION", NULL,
85
	"typeset", "-r", "KSH_VERSION", NULL,
85
	"typeset", "-r", "OKSH_VERSION", NULL,
86
	"typeset", "-r", "OKSH_VERSION", NULL,
87
#endif /* SMALL */
86
	"typeset", "-x", "SHELL", "PATH", "HOME", "PWD", "OLDPWD", NULL,
88
	"typeset", "-x", "SHELL", "PATH", "HOME", "PWD", "OLDPWD", NULL,
87
	"typeset", "-ir", "PPID", NULL,
89
	"typeset", "-ir", "PPID", NULL,
88
	"typeset", "-i", "OPTIND=1", NULL,
90
	"typeset", "-i", "OPTIND=1", NULL,
Lines 111-117 Link Here
111
113
112
char username[_PW_NAME_LEN + 1];
114
char username[_PW_NAME_LEN + 1];
113
115
116
#ifndef SMALL
114
#define version_param  (initcoms[2])
117
#define version_param  (initcoms[2])
118
#endif /* SMALL */
115
119
116
/* The shell uses its own variation on argv, to build variables like
120
/* The shell uses its own variation on argv, to build variables like
117
 * $0 and $@.
121
 * $0 and $@.
Lines 250-256 Link Here
250
	    (strlen(kshname) >= 3 &&
254
	    (strlen(kshname) >= 3 &&
251
	    !strcmp(&kshname[strlen(kshname) - 3], "/sh"))) {
255
	    !strcmp(&kshname[strlen(kshname) - 3], "/sh"))) {
252
		Flag(FSH) = 1;
256
		Flag(FSH) = 1;
257
#ifndef SMALL
253
		version_param = "SH_VERSION";
258
		version_param = "SH_VERSION";
259
#endif /* SMALL */
254
	}
260
	}
255
261
256
	/* Set edit mode to emacs by default, may be overridden
262
	/* Set edit mode to emacs by default, may be overridden
Lines 299-307 Link Here
299
	}
305
	}
300
	ppid = getppid();
306
	ppid = getppid();
301
	setint(global("PPID"), (int64_t) ppid);
307
	setint(global("PPID"), (int64_t) ppid);
308
#ifndef SMALL
302
	/* setstr can't fail here */
309
	/* setstr can't fail here */
303
	setstr(global(version_param), ksh_version, KSH_RETURN_ERROR);
310
	setstr(global(version_param), ksh_version, KSH_RETURN_ERROR);
304
	setstr(global("OKSH_VERSION"), "oksh 7.0", KSH_RETURN_ERROR);
311
	setstr(global("OKSH_VERSION"), "oksh 7.3", KSH_RETURN_ERROR);
312
#endif /* SMALL */
305
313
306
	/* execute initialization statements */
314
	/* execute initialization statements */
307
	for (wp = (char**) initcoms; *wp != NULL; wp++) {
315
	for (wp = (char**) initcoms; *wp != NULL; wp++) {
(-)oksh-7.0/misc.c (-4 / +4 lines)
Lines 1-4 Link Here
1
/*	$OpenBSD: misc.c,v 1.76 2020/10/26 18:16:51 tb Exp $	*/
1
/*	$OpenBSD: misc.c,v 1.78 2021/12/24 22:08:37 deraadt Exp $	*/
2
2
3
/*
3
/*
4
 * Miscellaneous functions
4
 * Miscellaneous functions
Lines 908-914 Link Here
908
			go->buf[0] = c;
908
			go->buf[0] = c;
909
			go->optarg = go->buf;
909
			go->optarg = go->buf;
910
		} else {
910
		} else {
911
			warningf(true, "%s%s-%c: unknown option",
911
			warningf(false, "%s%s-%c: unknown option",
912
			    (go->flags & GF_NONAME) ? "" : argv[0],
912
			    (go->flags & GF_NONAME) ? "" : argv[0],
913
			    (go->flags & GF_NONAME) ? "" : ": ", c);
913
			    (go->flags & GF_NONAME) ? "" : ": ", c);
914
			if (go->flags & GF_ERROR)
914
			if (go->flags & GF_ERROR)
Lines 934-940 Link Here
934
				go->optarg = go->buf;
934
				go->optarg = go->buf;
935
				return ':';
935
				return ':';
936
			}
936
			}
937
			warningf(true, "%s%s-`%c' requires argument",
937
			warningf(false, "%s%s-`%c' requires argument",
938
			    (go->flags & GF_NONAME) ? "" : argv[0],
938
			    (go->flags & GF_NONAME) ? "" : argv[0],
939
			    (go->flags & GF_NONAME) ? "" : ": ", c);
939
			    (go->flags & GF_NONAME) ? "" : ": ", c);
940
			if (go->flags & GF_ERROR)
940
			if (go->flags & GF_ERROR)
Lines 1138-1144 Link Here
1138
	/* Assume getcwd() available */
1138
	/* Assume getcwd() available */
1139
	if (!buf) {
1139
	if (!buf) {
1140
		bsize = PATH_MAX;
1140
		bsize = PATH_MAX;
1141
		b = alloc(PATH_MAX + 1, ATEMP);
1141
		b = alloc(bsize, ATEMP);
1142
	} else
1142
	} else
1143
		b = buf;
1143
		b = buf;
1144
1144
(-)oksh-7.0/oksh.1 (-16 / +9 lines)
Lines 1-8 Link Here
1
.\"	$OpenBSD: ksh.1,v 1.215 2021/05/04 21:03:30 naddy Exp $
1
.\"	$OpenBSD: ksh.1,v 1.218 2022/12/26 17:45:27 jmc Exp $
2
.\"
2
.\"
3
.\"	Public Domain
3
.\"	Public Domain
4
.\"
4
.\"
5
.Dd $Mdocdate: May 4 2021 $
5
.Dd $Mdocdate: December 26 2022 $
6
.Dt OKSH 1
6
.Dt OKSH 1
7
.Os
7
.Os
8
.Sh NAME
8
.Sh NAME
Lines 745-753 Link Here
745
must be unquoted.
745
must be unquoted.
746
.It
746
.It
747
The second operand of the
747
The second operand of the
748
.Sq !=
748
.Sq = ,
749
.Sq ==
749
and
750
and
750
.Sq =
751
.Sq !=
751
expressions are patterns (e.g. the comparison
752
expressions are patterns (e.g. the comparison
752
.Ic [[ foobar = f*r ]]
753
.Ic [[ foobar = f*r ]]
753
succeeds).
754
succeeds).
Lines 2712-2720 Link Here
2712
.Cm +-x Oc
2713
.Cm +-x Oc
2713
.Op Fl p
2714
.Op Fl p
2714
.Op Cm +
2715
.Op Cm +
2715
.Oo Ar name
2716
.Op Ar name Ns Oo = Ns Ar value Oc Ar ...
2716
.Op Ns = Ns Ar value
2717
.Ar ... Oc
2718
.Xc
2717
.Xc
2719
Without arguments,
2718
Without arguments,
2720
.Ic alias
2719
.Ic alias
Lines 3453-3461 Link Here
3453
.It Xo
3452
.It Xo
3454
.Ic readonly
3453
.Ic readonly
3455
.Op Fl p
3454
.Op Fl p
3456
.Oo Ar parameter
3455
.Op Ar parameter Ns Oo = Ns Ar value Oc Ar ...
3457
.Op Ns = Ns Ar value
3458
.Ar ... Oc
3459
.Xc
3456
.Xc
3460
Sets the read-only attribute of the named parameters.
3457
Sets the read-only attribute of the named parameters.
3461
If values are given,
3458
If values are given,
Lines 4012-4018 Link Here
4012
.Pp
4009
.Pp
4013
If the
4010
If the
4014
.Fl p
4011
.Fl p
4015
option is given the output is slightly longer:
4012
option is given, the output is slightly longer:
4016
.Bd -literal -offset indent
4013
.Bd -literal -offset indent
4017
real     0.00
4014
real     0.00
4018
user     0.00
4015
user     0.00
Lines 4124-4134 Link Here
4124
.Op Fl i Ns Op Ar n
4121
.Op Fl i Ns Op Ar n
4125
.No \&| Fl f Op Fl tux
4122
.No \&| Fl f Op Fl tux
4126
.Oc
4123
.Oc
4127
.Oo
4124
.Op Ar name Ns Oo = Ns Ar value Oc Ar ...
4128
.Ar name
4129
.Op Ns = Ns Ar value
4130
.Ar ...
4131
.Oc
4132
.Xc
4125
.Xc
4133
Display or set parameter attributes.
4126
Display or set parameter attributes.
4134
With no
4127
With no
(-)oksh-7.0/sh.1 (-9 / +9 lines)
Lines 1-4 Link Here
1
.\"	$OpenBSD: sh.1,v 1.153 2021/05/04 21:03:31 naddy Exp $
1
.\"	$OpenBSD: sh.1,v 1.156 2022/12/19 08:19:50 sdk Exp $
2
.\"
2
.\"
3
.\" Copyright (c) 2015 Jason McIntyre <jmc@openbsd.org>
3
.\" Copyright (c) 2015 Jason McIntyre <jmc@openbsd.org>
4
.\"
4
.\"
Lines 14-20 Link Here
14
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
.\"
16
.\"
17
.Dd $Mdocdate: May 4 2021 $
17
.Dd $Mdocdate: December 19 2022 $
18
.Dt SH 1
18
.Dt SH 1
19
.Os
19
.Os
20
.Sh NAME
20
.Sh NAME
Lines 752-760 Link Here
752
and so on.
752
and so on.
753
Parameters
753
Parameters
754
.Sq #
754
.Sq #
755
to
755
down to
756
.Sq Po #\(mi Ns Ar n Pc Ns +1
756
.Sq Po #\(mi Ns Ar n Pc Ns +1
757
and downwards are unset and
757
are unset and
758
.Sq #
758
.Sq #
759
is updated to the new number of positional parameters.
759
is updated to the new number of positional parameters.
760
If
760
If
Lines 1052-1060 Link Here
1052
.Ic 0 , ^ , $ ,
1052
.Ic 0 , ^ , $ ,
1053
and
1053
and
1054
.Ic c .
1054
.Ic c .
1055
If the motion moves towards the beginning of the line
1055
If the motion moves towards the beginning of the line,
1056
the character under the cursor is not deleted;
1056
the character under the cursor is not deleted;
1057
if it moves towards the end of the line
1057
if it moves towards the end of the line,
1058
it is deleted.
1058
it is deleted.
1059
.It Ic C
1059
.It Ic C
1060
Delete the characters between the cursor and the line end,
1060
Delete the characters between the cursor and the line end,
Lines 1089-1095 Link Here
1089
A special motion command,
1089
A special motion command,
1090
.Ic d ,
1090
.Ic d ,
1091
may be used to delete the entire line.
1091
may be used to delete the entire line.
1092
If the motion moves towards the beginning of the line
1092
If the motion moves towards the beginning of the line,
1093
the character under the cursor is not deleted.
1093
the character under the cursor is not deleted.
1094
.It Oo Ar count Oc Ns Ic D
1094
.It Oo Ar count Oc Ns Ic D
1095
Delete the characters between the cursor and the line end,
1095
Delete the characters between the cursor and the line end,
Lines 1100-1106 Link Here
1100
A special motion command,
1100
A special motion command,
1101
.Ic y ,
1101
.Ic y ,
1102
may be used to yank the entire line.
1102
may be used to yank the entire line.
1103
If the motion moves towards the beginning of the line
1103
If the motion moves towards the beginning of the line,
1104
the character under the cursor is not yanked.
1104
the character under the cursor is not yanked.
1105
.It Oo Ar count Oc Ns Ic Y
1105
.It Oo Ar count Oc Ns Ic Y
1106
Yank (copy) the characters between the cursor and the line end,
1106
Yank (copy) the characters between the cursor and the line end,
Lines 1390-1396 Link Here
1390
.Pp
1390
.Pp
1391
Where
1391
Where
1392
.Ar expression
1392
.Ar expression
1393
is an integer, parameter name, or array reference,
1393
is an integer or parameter name,
1394
optionally combined with any of the operators described below,
1394
optionally combined with any of the operators described below,
1395
listed and grouped according to precedence:
1395
listed and grouped according to precedence:
1396
.Bl -tag -width Ds
1396
.Bl -tag -width Ds
(-)oksh-7.0/tty.c (-2 / +2 lines)
Lines 1-4 Link Here
1
/*	$OpenBSD: tty.c,v 1.18 2019/06/28 13:34:59 deraadt Exp $	*/
1
/*	$OpenBSD: tty.c,v 1.19 2021/10/24 21:24:21 deraadt Exp $	*/
2
2
3
#include <errno.h>
3
#include <errno.h>
4
#include <fcntl.h>
4
#include <fcntl.h>
Lines 33-39 Link Here
33
	tty_close();
33
	tty_close();
34
	tty_devtty = 1;
34
	tty_devtty = 1;
35
35
36
	tfd = open("/dev/tty", O_RDWR, 0);
36
	tfd = open("/dev/tty", O_RDWR);
37
	if (tfd == -1) {
37
	if (tfd == -1) {
38
		tty_devtty = 0;
38
		tty_devtty = 0;
39
		warningf(false, "No controlling tty (open /dev/tty: %s)",
39
		warningf(false, "No controlling tty (open /dev/tty: %s)",
(-)oksh-7.0/vi.c (+8 lines)
Lines 15-22 Link Here
15
#include <stdlib.h>
15
#include <stdlib.h>
16
#include <string.h>
16
#include <string.h>
17
#if !defined(SMALL) && !defined(NO_CURSES)
17
#if !defined(SMALL) && !defined(NO_CURSES)
18
#ifdef HAVE_CURSES
18
# include <term.h>
19
# include <term.h>
19
# include <curses.h>
20
# include <curses.h>
21
#elif defined(HAVE_NCURSES)
22
# include <term.h>
23
# include <ncurses.h>
24
#elif defined(HAVE_NCURSESNCURSES)
25
# include <ncurses/term.h>
26
# include <ncurses/ncurses.h>
27
#endif
20
#endif
28
#endif
21
29
22
#include "sh.h"
30
#include "sh.h"

Return to bug 46317