Oh well… this looks well, is done done, and gcc-snapshot doesn’t complain:
• correct order of built-in commands; use POSIX special versus “all others” plus “keeps assignments” as distinction, no longer play POSIX regular vs. others game; sync manpage • fix LP#1156707: map (( internally to “let]” which is no valid function name and so can’t be overridden but is unlikely to be used otherwhere and not strictly permitted (by POSIX) anyway • we do not need -Wno-overflow any more, either • bump to R45
This commit is contained in:
8
Build.sh
8
Build.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.626 2013/04/26 19:40:07 tg Exp $'
|
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.627 2013/04/26 21:22:39 tg Exp $'
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012, 2013
|
# 2011, 2012, 2013
|
||||||
@ -1177,7 +1177,6 @@ i=0
|
|||||||
if test $ct = gcc; then
|
if test $ct = gcc; then
|
||||||
# The following tests run with -Werror (gcc only) if possible
|
# The following tests run with -Werror (gcc only) if possible
|
||||||
NOWARN=$DOWARN; phase=u
|
NOWARN=$DOWARN; phase=u
|
||||||
ac_flags 0 wnooverflow -Wno-overflow
|
|
||||||
# mksh is not written in CFrustFrust!
|
# mksh is not written in CFrustFrust!
|
||||||
ac_flags 1 no_eh_frame -fno-asynchronous-unwind-tables
|
ac_flags 1 no_eh_frame -fno-asynchronous-unwind-tables
|
||||||
ac_flags 1 fnostrictaliasing -fno-strict-aliasing
|
ac_flags 1 fnostrictaliasing -fno-strict-aliasing
|
||||||
@ -1532,7 +1531,7 @@ else
|
|||||||
#define EXTERN
|
#define EXTERN
|
||||||
#define MKSH_INCLUDES_ONLY
|
#define MKSH_INCLUDES_ONLY
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.626 2013/04/26 19:40:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.627 2013/04/26 21:22:39 tg Exp $");
|
||||||
int main(void) { printf("Hello, World!\n"); return (0); }
|
int main(void) { printf("Hello, World!\n"); return (0); }
|
||||||
EOF
|
EOF
|
||||||
case $cm in
|
case $cm in
|
||||||
@ -1848,7 +1847,6 @@ ac_testdone
|
|||||||
ac_cppflags
|
ac_cppflags
|
||||||
|
|
||||||
save_CFLAGS=$CFLAGS
|
save_CFLAGS=$CFLAGS
|
||||||
test x1 = x$HAVE_CAN_WNOOVERFLOW && CFLAGS="$CFLAGS -Wno-overflow"
|
|
||||||
ac_testn compile_time_asserts_$$ '' 'whether compile-time assertions pass' <<-'EOF'
|
ac_testn compile_time_asserts_$$ '' 'whether compile-time assertions pass' <<-'EOF'
|
||||||
#define MKSH_INCLUDES_ONLY
|
#define MKSH_INCLUDES_ONLY
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
@ -2048,7 +2046,7 @@ addsrcs USE_PRINTF_BUILTIN printf.c
|
|||||||
test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
|
test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
|
||||||
test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
|
test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
|
||||||
test -n "$LDSTATIC" && add_cppflags -DMKSH_OPTSTATIC
|
test -n "$LDSTATIC" && add_cppflags -DMKSH_OPTSTATIC
|
||||||
add_cppflags -DMKSH_BUILD_R=449
|
add_cppflags -DMKSH_BUILD_R=451
|
||||||
|
|
||||||
$e $bi$me: Finished configuration testing, now producing output.$ao
|
$e $bi$me: Finished configuration testing, now producing output.$ao
|
||||||
|
|
||||||
|
4
Makefile
4
Makefile
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/Makefile,v 1.116 2013/04/26 19:40:09 tg Exp $
|
# $MirOS: src/bin/mksh/Makefile,v 1.117 2013/04/26 21:22:40 tg Exp $
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012, 2013
|
# 2011, 2012, 2013
|
||||||
@ -54,7 +54,7 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 -DMKSH_DISABLE_DEPRECATED \
|
|||||||
-DHAVE_SETGROUPS=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 \
|
-DHAVE_SETGROUPS=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 \
|
||||||
-DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \
|
-DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \
|
||||||
-DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
|
-DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
|
||||||
-DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=449
|
-DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=451
|
||||||
CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U}
|
CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U}
|
||||||
COPTS+= -std=c99 -Wall
|
COPTS+= -std=c99 -Wall
|
||||||
.endif
|
.endif
|
||||||
|
30
check.t
30
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.606 2013/04/26 19:40:42 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.607 2013/04/26 21:22:42 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -29,7 +29,7 @@
|
|||||||
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R44 2013/04/26
|
@(#)MIRBSD KSH R45 2013/04/26
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -38,7 +38,7 @@ name: KSH_VERSION
|
|||||||
category: shell:legacy-no
|
category: shell:legacy-no
|
||||||
---
|
---
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)LEGACY KSH R44 2013/04/26
|
@(#)LEGACY KSH R45 2013/04/26
|
||||||
description:
|
description:
|
||||||
Check version of legacy shell.
|
Check version of legacy shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -9090,7 +9090,7 @@ expected-stdout:
|
|||||||
}
|
}
|
||||||
inline_TWHILE() {
|
inline_TWHILE() {
|
||||||
i=1
|
i=1
|
||||||
while let " i < 10 "
|
while let] " i < 10 "
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
let ++i
|
let ++i
|
||||||
@ -9100,20 +9100,20 @@ expected-stdout:
|
|||||||
i=1; while (( i < 10 )); do echo $i; let ++i; done
|
i=1; while (( i < 10 )); do echo $i; let ++i; done
|
||||||
); }
|
); }
|
||||||
function comsub_TWHILE {
|
function comsub_TWHILE {
|
||||||
x=$(i=1 ; while let " i < 10 " ; do echo $i ; let ++i ; done )
|
x=$(i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done )
|
||||||
}
|
}
|
||||||
function reread_TWHILE { x=$((
|
function reread_TWHILE { x=$((
|
||||||
i=1; while (( i < 10 )); do echo $i; let ++i; done
|
i=1; while (( i < 10 )); do echo $i; let ++i; done
|
||||||
)|tr u x); }
|
)|tr u x); }
|
||||||
function reread_TWHILE {
|
function reread_TWHILE {
|
||||||
x=$(( i=1 ; while let " i < 10 " ; do echo $i ; let ++i ; done ) | tr u x )
|
x=$(( i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done ) | tr u x )
|
||||||
}
|
}
|
||||||
inline_TUNTIL() {
|
inline_TUNTIL() {
|
||||||
i=10; until (( !--i )) ; do echo $i; done
|
i=10; until (( !--i )) ; do echo $i; done
|
||||||
}
|
}
|
||||||
inline_TUNTIL() {
|
inline_TUNTIL() {
|
||||||
i=10
|
i=10
|
||||||
until let " !--i "
|
until let] " !--i "
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
done
|
done
|
||||||
@ -9122,13 +9122,13 @@ expected-stdout:
|
|||||||
i=10; until (( !--i )) ; do echo $i; done
|
i=10; until (( !--i )) ; do echo $i; done
|
||||||
); }
|
); }
|
||||||
function comsub_TUNTIL {
|
function comsub_TUNTIL {
|
||||||
x=$(i=10 ; until let " !--i " ; do echo $i ; done )
|
x=$(i=10 ; until let] " !--i " ; do echo $i ; done )
|
||||||
}
|
}
|
||||||
function reread_TUNTIL { x=$((
|
function reread_TUNTIL { x=$((
|
||||||
i=10; until (( !--i )) ; do echo $i; done
|
i=10; until (( !--i )) ; do echo $i; done
|
||||||
)|tr u x); }
|
)|tr u x); }
|
||||||
function reread_TUNTIL {
|
function reread_TUNTIL {
|
||||||
x=$(( i=10 ; until let " !--i " ; do echo $i ; done ) | tr u x )
|
x=$(( i=10 ; until let] " !--i " ; do echo $i ; done ) | tr u x )
|
||||||
}
|
}
|
||||||
inline_TCOPROC() {
|
inline_TCOPROC() {
|
||||||
cat * |& ls
|
cat * |& ls
|
||||||
@ -9742,7 +9742,7 @@ expected-stdout:
|
|||||||
}
|
}
|
||||||
inline_TWHILE() {
|
inline_TWHILE() {
|
||||||
i=1
|
i=1
|
||||||
while let " i < 10 " >&3
|
while let] " i < 10 " >&3
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
let ++i
|
let ++i
|
||||||
@ -9752,20 +9752,20 @@ expected-stdout:
|
|||||||
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
|
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
|
||||||
); }
|
); }
|
||||||
function comsub_TWHILE {
|
function comsub_TWHILE {
|
||||||
x=$(i=1 ; while let " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 )
|
x=$(i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 )
|
||||||
}
|
}
|
||||||
function reread_TWHILE { x=$((
|
function reread_TWHILE { x=$((
|
||||||
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
|
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
|
||||||
)|tr u x); }
|
)|tr u x); }
|
||||||
function reread_TWHILE {
|
function reread_TWHILE {
|
||||||
x=$(( i=1 ; while let " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
|
x=$(( i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
|
||||||
}
|
}
|
||||||
inline_TUNTIL() {
|
inline_TUNTIL() {
|
||||||
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
||||||
}
|
}
|
||||||
inline_TUNTIL() {
|
inline_TUNTIL() {
|
||||||
i=10
|
i=10
|
||||||
until let " !--i " >&3
|
until let] " !--i " >&3
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
done >&3
|
done >&3
|
||||||
@ -9774,13 +9774,13 @@ expected-stdout:
|
|||||||
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
||||||
); }
|
); }
|
||||||
function comsub_TUNTIL {
|
function comsub_TUNTIL {
|
||||||
x=$(i=10 ; until let " !--i " >&3 ; do echo $i ; done >&3 )
|
x=$(i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 )
|
||||||
}
|
}
|
||||||
function reread_TUNTIL { x=$((
|
function reread_TUNTIL { x=$((
|
||||||
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
||||||
)|tr u x); }
|
)|tr u x); }
|
||||||
function reread_TUNTIL {
|
function reread_TUNTIL {
|
||||||
x=$(( i=10 ; until let " !--i " >&3 ; do echo $i ; done >&3 ) | tr u x )
|
x=$(( i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 ) | tr u x )
|
||||||
}
|
}
|
||||||
inline_TCOPROC() {
|
inline_TCOPROC() {
|
||||||
cat * >&3 |& >&3 ls
|
cat * >&3 |& >&3 ls
|
||||||
|
18
exec.c
18
exec.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.119 2013/04/26 19:47:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.120 2013/04/26 21:22:44 tg Exp $");
|
||||||
|
|
||||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||||
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
||||||
@ -1047,25 +1047,23 @@ const char *
|
|||||||
builtin(const char *name, int (*func) (const char **))
|
builtin(const char *name, int (*func) (const char **))
|
||||||
{
|
{
|
||||||
struct tbl *tp;
|
struct tbl *tp;
|
||||||
uint32_t flag;
|
uint32_t flag = DEFINED;
|
||||||
|
|
||||||
/* see if any flags should be set for this builtin */
|
/* see if any flags should be set for this builtin */
|
||||||
for (flag = 0; ; name++) {
|
while (1) {
|
||||||
if (*name == '=')
|
if (*name == '=')
|
||||||
/* command does variable assignment */
|
/* command does variable assignment */
|
||||||
flag |= KEEPASN;
|
flag |= KEEPASN;
|
||||||
else if (*name == '*')
|
else if (*name == '*')
|
||||||
/* POSIX special builtin */
|
/* POSIX special builtin */
|
||||||
flag |= SPEC_BI;
|
flag |= SPEC_BI;
|
||||||
else if (*name == '+')
|
|
||||||
/* POSIX regular builtin */
|
|
||||||
flag |= REG_BI;
|
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
name++;
|
||||||
}
|
}
|
||||||
|
|
||||||
tp = ktenter(&builtins, name, hash(name));
|
tp = ktenter(&builtins, name, hash(name));
|
||||||
tp->flag = DEFINED | flag;
|
tp->flag = flag;
|
||||||
tp->type = CSHELL;
|
tp->type = CSHELL;
|
||||||
tp->val.f = func;
|
tp->val.f = func;
|
||||||
|
|
||||||
@ -1097,7 +1095,7 @@ findcom(const char *name, int flags)
|
|||||||
tbi = (flags & FC_BI) ? ktsearch(&builtins, name, h) : NULL;
|
tbi = (flags & FC_BI) ? ktsearch(&builtins, name, h) : NULL;
|
||||||
/*
|
/*
|
||||||
* POSIX says special builtins first, then functions, then
|
* POSIX says special builtins first, then functions, then
|
||||||
* POSIX regular builtins, then search path...
|
* regular builtins, then search path...
|
||||||
*/
|
*/
|
||||||
if ((flags & FC_SPECBI) && tbi && (tbi->flag & SPEC_BI))
|
if ((flags & FC_SPECBI) && tbi && (tbi->flag & SPEC_BI))
|
||||||
tp = tbi;
|
tp = tbi;
|
||||||
@ -1112,9 +1110,7 @@ findcom(const char *name, int flags)
|
|||||||
&tp->u2.errnov);
|
&tp->u2.errnov);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!tp && (flags & FC_REGBI) && tbi && (tbi->flag & REG_BI))
|
if (!tp && (flags & FC_NORMBI) && tbi)
|
||||||
tp = tbi;
|
|
||||||
if (!tp && (flags & FC_UNREGBI) && tbi)
|
|
||||||
tp = tbi;
|
tp = tbi;
|
||||||
if (!tp && (flags & FC_PATH) && !(flags & FC_DEFPATH)) {
|
if (!tp && (flags & FC_PATH) && !(flags & FC_DEFPATH)) {
|
||||||
tp = ktsearch(&taliases, name, h);
|
tp = ktsearch(&taliases, name, h);
|
||||||
|
79
funcs.c
79
funcs.c
@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.241 2013/04/26 17:39:28 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.242 2013/04/26 21:22:45 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -84,70 +84,69 @@ c_false(const char **wp MKSH_A_UNUSED)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A leading = means assignments before command are kept;
|
* A leading = means assignments before command are kept.
|
||||||
* a leading * means a POSIX special builtin;
|
* A leading * means a POSIX special builtin.
|
||||||
* a leading + means a POSIX regular builtin
|
|
||||||
* (* and + should not be combined).
|
|
||||||
*/
|
*/
|
||||||
const struct builtin mkshbuiltins[] = {
|
const struct builtin mkshbuiltins[] = {
|
||||||
{"*=.", c_dot},
|
{"*=.", c_dot},
|
||||||
{"*=:", c_true},
|
{"*=:", c_true},
|
||||||
{"[", c_test},
|
{"[", c_test},
|
||||||
|
/* no =: AT&T manual wrong */
|
||||||
|
{Talias, c_alias},
|
||||||
{"*=break", c_brkcont},
|
{"*=break", c_brkcont},
|
||||||
{Tgbuiltin, c_builtin},
|
{Tgbuiltin, c_builtin},
|
||||||
|
{"cat", c_cat},
|
||||||
|
{"cd", c_cd},
|
||||||
|
/* dash compatibility hack */
|
||||||
|
{"chdir", c_cd},
|
||||||
|
{"command", c_command},
|
||||||
{"*=continue", c_brkcont},
|
{"*=continue", c_brkcont},
|
||||||
|
{"echo", c_print},
|
||||||
{"*=eval", c_eval},
|
{"*=eval", c_eval},
|
||||||
{"*=exec", c_exec},
|
{"*=exec", c_exec},
|
||||||
{"*=exit", c_exitreturn},
|
{"*=exit", c_exitreturn},
|
||||||
{"+false", c_false},
|
{Tsgexport, c_typeset},
|
||||||
|
{"false", c_false},
|
||||||
|
{"fc", c_fc},
|
||||||
|
{"getopts", c_getopts},
|
||||||
|
{"=global", c_typeset},
|
||||||
|
{"jobs", c_jobs},
|
||||||
|
{"kill", c_kill},
|
||||||
|
{"let", c_let},
|
||||||
|
{"let]", c_let},
|
||||||
|
{"print", c_print},
|
||||||
|
{"pwd", c_pwd},
|
||||||
|
{"read", c_read},
|
||||||
|
{Tsgreadonly, c_typeset},
|
||||||
|
{"realpath", c_realpath},
|
||||||
|
{"rename", c_rename},
|
||||||
{"*=return", c_exitreturn},
|
{"*=return", c_exitreturn},
|
||||||
{Tsgset, c_set},
|
{Tsgset, c_set},
|
||||||
{"*=shift", c_shift},
|
{"*=shift", c_shift},
|
||||||
{"=times", c_times},
|
|
||||||
{"*=trap", c_trap},
|
|
||||||
{"+=wait", c_wait},
|
|
||||||
{"+read", c_read},
|
|
||||||
{"test", c_test},
|
{"test", c_test},
|
||||||
{"+true", c_true},
|
{"*=times", c_times},
|
||||||
{"ulimit", c_ulimit},
|
{"*=trap", c_trap},
|
||||||
{"+umask", c_umask},
|
{"true", c_true},
|
||||||
{Tsgunset, c_unset},
|
|
||||||
/* no =: AT&T manual wrong */
|
|
||||||
{Tpalias, c_alias},
|
|
||||||
{"+cd", c_cd},
|
|
||||||
/* dash compatibility hack */
|
|
||||||
{"chdir", c_cd},
|
|
||||||
{"+command", c_command},
|
|
||||||
{"echo", c_print},
|
|
||||||
{Tsgexport, c_typeset},
|
|
||||||
{"+fc", c_fc},
|
|
||||||
{"+getopts", c_getopts},
|
|
||||||
{"=global", c_typeset},
|
|
||||||
{"+jobs", c_jobs},
|
|
||||||
{"+kill", c_kill},
|
|
||||||
{"let", c_let},
|
|
||||||
{"print", c_print},
|
|
||||||
#ifdef MKSH_PRINTF_BUILTIN
|
|
||||||
{"printf", c_printf},
|
|
||||||
#endif
|
|
||||||
{"pwd", c_pwd},
|
|
||||||
{Tsgreadonly, c_typeset},
|
|
||||||
{T_typeset, c_typeset},
|
{T_typeset, c_typeset},
|
||||||
{Tpunalias, c_unalias},
|
{"ulimit", c_ulimit},
|
||||||
|
{"umask", c_umask},
|
||||||
|
{Tunalias, c_unalias},
|
||||||
|
{Tsgunset, c_unset},
|
||||||
|
{"=wait", c_wait},
|
||||||
{"whence", c_whence},
|
{"whence", c_whence},
|
||||||
#ifndef MKSH_UNEMPLOYED
|
#ifndef MKSH_UNEMPLOYED
|
||||||
{"+bg", c_fgbg},
|
{"bg", c_fgbg},
|
||||||
{"+fg", c_fgbg},
|
{"fg", c_fgbg},
|
||||||
#endif
|
#endif
|
||||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||||
{"bind", c_bind},
|
{"bind", c_bind},
|
||||||
#endif
|
#endif
|
||||||
{"cat", c_cat},
|
|
||||||
#if HAVE_MKNOD
|
#if HAVE_MKNOD
|
||||||
{"mknod", c_mknod},
|
{"mknod", c_mknod},
|
||||||
#endif
|
#endif
|
||||||
{"realpath", c_realpath},
|
#ifdef MKSH_PRINTF_BUILTIN
|
||||||
{"rename", c_rename},
|
{"printf", c_printf},
|
||||||
|
#endif
|
||||||
#if HAVE_SELECT
|
#if HAVE_SELECT
|
||||||
{"sleep", c_sleep},
|
{"sleep", c_sleep},
|
||||||
#endif
|
#endif
|
||||||
|
4
main.c
4
main.c
@ -34,7 +34,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.261 2013/03/29 17:33:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.262 2013/04/26 21:22:46 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
|||||||
|
|
||||||
/* define built-in commands and see if we were called as one */
|
/* define built-in commands and see if we were called as one */
|
||||||
ktinit(APERM, &builtins,
|
ktinit(APERM, &builtins,
|
||||||
/* currently up to 50 builtins: 75% of 128 = 2^7 */
|
/* currently up to 51 builtins: 75% of 128 = 2^7 */
|
||||||
7);
|
7);
|
||||||
for (i = 0; mkshbuiltins[i].name != NULL; i++)
|
for (i = 0; mkshbuiltins[i].name != NULL; i++)
|
||||||
if (!strcmp(ccp, builtin(mkshbuiltins[i].name,
|
if (!strcmp(ccp, builtin(mkshbuiltins[i].name,
|
||||||
|
63
mksh.1
63
mksh.1
@ -1,4 +1,4 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.309 2013/04/14 13:36:53 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.310 2013/04/26 21:22:47 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.146 2013/03/18 11:10:52 mpi Exp $
|
.\" $OpenBSD: ksh.1,v 1.146 2013/03/18 11:10:52 mpi Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||||
@ -74,7 +74,7 @@
|
|||||||
.\" with -mandoc, it might implement .Mx itself, but we want to
|
.\" with -mandoc, it might implement .Mx itself, but we want to
|
||||||
.\" use our own definition. And .Dd must come *first*, always.
|
.\" use our own definition. And .Dd must come *first*, always.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: April 14 2013 $
|
.Dd $Mdocdate: April 26 2013 $
|
||||||
.\"
|
.\"
|
||||||
.\" Check which macro package we use, and do other -mdoc setup.
|
.\" Check which macro package we use, and do other -mdoc setup.
|
||||||
.\"
|
.\"
|
||||||
@ -2768,8 +2768,7 @@ However, unlike
|
|||||||
shell arguments (i.e. positional parameters $1, $2, etc.)\&
|
shell arguments (i.e. positional parameters $1, $2, etc.)\&
|
||||||
are never visible inside them.
|
are never visible inside them.
|
||||||
When the shell is determining the location of a command, functions
|
When the shell is determining the location of a command, functions
|
||||||
are searched after special built-in commands, before regular and
|
are searched after special built-in commands, before builtins and the
|
||||||
non-regular built-ins, and before the
|
|
||||||
.Ev PATH
|
.Ev PATH
|
||||||
is searched.
|
is searched.
|
||||||
.Pp
|
.Pp
|
||||||
@ -2883,8 +2882,8 @@ returns.
|
|||||||
.El
|
.El
|
||||||
.Ss Command execution
|
.Ss Command execution
|
||||||
After evaluation of command-line arguments, redirections, and parameter
|
After evaluation of command-line arguments, redirections, and parameter
|
||||||
assignments, the type of command is determined: a special built-in, a
|
assignments, the type of command is determined: a special built-in command,
|
||||||
function, a regular built-in, or the name of a file to execute found using the
|
a function, a normal builtin, or the name of a file to execute found using the
|
||||||
.Ev PATH
|
.Ev PATH
|
||||||
parameter.
|
parameter.
|
||||||
The checks are made in the above order.
|
The checks are made in the above order.
|
||||||
@ -2900,46 +2899,30 @@ parameter is not used to find them.
|
|||||||
The original
|
The original
|
||||||
.Nm ksh
|
.Nm ksh
|
||||||
and POSIX differ somewhat in which commands are considered
|
and POSIX differ somewhat in which commands are considered
|
||||||
special or regular:
|
special or regular.
|
||||||
.Pp
|
.Pp
|
||||||
POSIX special commands
|
POSIX special built-in utilities:
|
||||||
.Pp
|
.Pp
|
||||||
.Ic \&. , \&: , break , continue ,
|
.Ic \&. , \&: , break , continue ,
|
||||||
.Ic eval , exec , exit , export ,
|
.Ic eval , exec , exit , export ,
|
||||||
.Ic readonly , return , set , shift ,
|
.Ic readonly , return , set , shift ,
|
||||||
.Ic trap , unset , wait
|
.Ic times , trap , unset
|
||||||
.Pp
|
.Pp
|
||||||
Additional
|
Additional
|
||||||
.Nm
|
.Nm
|
||||||
special commands
|
commands keeping assignments:
|
||||||
.Pp
|
.Pp
|
||||||
.Ic builtin , global , times , typeset
|
.Ic builtin , global , typeset , wait
|
||||||
.Pp
|
.Pp
|
||||||
Very special commands
|
Builtins that are not special:
|
||||||
.Pq non-POSIX
|
|
||||||
.Pp
|
.Pp
|
||||||
.Ic alias , readonly , set , typeset
|
.Ic [ , alias , bg , bind ,
|
||||||
.Pp
|
.Ic cat , cd , command , echo ,
|
||||||
POSIX regular commands
|
|
||||||
.Pp
|
|
||||||
.Ic alias , bg , cd , command ,
|
|
||||||
.Ic false , fc , fg , getopts ,
|
.Ic false , fc , fg , getopts ,
|
||||||
.Ic jobs , kill , read , true ,
|
.Ic jobs , kill , let , mknod ,
|
||||||
.Ic umask , unalias
|
.Ic print , pwd , read , realpath ,
|
||||||
.Pp
|
.Ic rename , sleep , test , true ,
|
||||||
Additional
|
.Ic ulimit , umask , unalias , whence
|
||||||
.Nm
|
|
||||||
regular commands
|
|
||||||
.Pp
|
|
||||||
.Ic \&[ , chdir , bind , cat ,
|
|
||||||
.Ic echo , let , mknod , print ,
|
|
||||||
.Ic pwd , realpath , rename , sleep ,
|
|
||||||
.Ic test , ulimit , whence
|
|
||||||
.Pp
|
|
||||||
In the future, the additional
|
|
||||||
.Nm
|
|
||||||
special and regular commands may be treated
|
|
||||||
differently from the POSIX special and regular commands.
|
|
||||||
.Pp
|
.Pp
|
||||||
Once the type of command has been determined, any command-line parameter
|
Once the type of command has been determined, any command-line parameter
|
||||||
assignments are performed and exported for the duration of the command.
|
assignments are performed and exported for the duration of the command.
|
||||||
@ -2967,6 +2950,10 @@ those of the environment the command is used in.
|
|||||||
The null command.
|
The null command.
|
||||||
Exit status is set to zero.
|
Exit status is set to zero.
|
||||||
.Pp
|
.Pp
|
||||||
|
.It Ic \&[ Ar expression Ic \&]
|
||||||
|
See
|
||||||
|
.Ic test .
|
||||||
|
.Pp
|
||||||
.It Xo Ic alias
|
.It Xo Ic alias
|
||||||
.Oo Fl d \*(Ba t Oo Fl r Oc \*(Ba
|
.Oo Fl d \*(Ba t Oo Fl r Oc \*(Ba
|
||||||
.Cm +\-x Oc
|
.Cm +\-x Oc
|
||||||
@ -3521,6 +3508,10 @@ resetting
|
|||||||
.Ev OPTIND ,
|
.Ev OPTIND ,
|
||||||
may lead to unexpected results.
|
may lead to unexpected results.
|
||||||
.Pp
|
.Pp
|
||||||
|
.It global Ar ...
|
||||||
|
See
|
||||||
|
.Ic typeset .
|
||||||
|
.Pp
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic hash
|
.Ic hash
|
||||||
.Op Fl r
|
.Op Fl r
|
||||||
@ -3600,6 +3591,10 @@ Since expressions may need to be quoted,
|
|||||||
is syntactic sugar for
|
is syntactic sugar for
|
||||||
.No let \&" Ns Ar expr Ns \&" .
|
.No let \&" Ns Ar expr Ns \&" .
|
||||||
.Pp
|
.Pp
|
||||||
|
.It let]
|
||||||
|
Internally used alias for
|
||||||
|
.Ic let .
|
||||||
|
.Pp
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic mknod
|
.Ic mknod
|
||||||
.Op Fl m Ar mode
|
.Op Fl m Ar mode
|
||||||
|
24
sh.h
24
sh.h
@ -164,9 +164,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.650 2013/04/26 19:40:45 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.651 2013/04/26 21:22:49 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R44 2013/04/26"
|
#define MKSH_VERSION "R45 2013/04/26"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
@ -520,7 +520,7 @@ char *ucstrstr(char *, const char *);
|
|||||||
#define mkssert(e) do { } while (/* CONSTCOND */ 0)
|
#define mkssert(e) do { } while (/* CONSTCOND */ 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 449)
|
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 451)
|
||||||
#error Must run Build.sh to compile this.
|
#error Must run Build.sh to compile this.
|
||||||
int
|
int
|
||||||
im_sorry_dave(void)
|
im_sorry_dave(void)
|
||||||
@ -797,10 +797,8 @@ EXTERN const char Tr_fc_e_dash[] E_INIT("r=fc -e -");
|
|||||||
EXTERN const char Tlocal_typeset[] E_INIT("local=typeset");
|
EXTERN const char Tlocal_typeset[] E_INIT("local=typeset");
|
||||||
#define T_typeset (Tlocal_typeset + 5) /* "=typeset" */
|
#define T_typeset (Tlocal_typeset + 5) /* "=typeset" */
|
||||||
#define Ttypeset (Tlocal_typeset + 6) /* "typeset" */
|
#define Ttypeset (Tlocal_typeset + 6) /* "typeset" */
|
||||||
EXTERN const char Tpalias[] E_INIT("+alias");
|
EXTERN const char Talias[] E_INIT("alias");
|
||||||
#define Talias (Tpalias + 1) /* "alias" */
|
EXTERN const char Tunalias[] E_INIT("unalias");
|
||||||
EXTERN const char Tpunalias[] E_INIT("+unalias");
|
|
||||||
#define Tunalias (Tpunalias + 1) /* "unalias" */
|
|
||||||
EXTERN const char Tsgset[] E_INIT("*=set");
|
EXTERN const char Tsgset[] E_INIT("*=set");
|
||||||
#define Tset (Tsgset + 2) /* "set" */
|
#define Tset (Tsgset + 2) /* "set" */
|
||||||
EXTERN const char Tsgunset[] E_INIT("*=unset");
|
EXTERN const char Tsgunset[] E_INIT("*=unset");
|
||||||
@ -1160,7 +1158,6 @@ EXTERN struct tbl vtemp;
|
|||||||
#define FDELETE BIT(10) /* function deleted while it was executing */
|
#define FDELETE BIT(10) /* function deleted while it was executing */
|
||||||
#define FKSH BIT(11) /* function defined with function x (vs x()) */
|
#define FKSH BIT(11) /* function defined with function x (vs x()) */
|
||||||
#define SPEC_BI BIT(12) /* a POSIX special builtin */
|
#define SPEC_BI BIT(12) /* a POSIX special builtin */
|
||||||
#define REG_BI BIT(13) /* a POSIX regular builtin */
|
|
||||||
/*
|
/*
|
||||||
* Attributes that can be set by the user (used to decide if an unset
|
* Attributes that can be set by the user (used to decide if an unset
|
||||||
* param should be repoted by set/typeset). Does not include ARRAY or
|
* param should be repoted by set/typeset). Does not include ARRAY or
|
||||||
@ -1189,12 +1186,11 @@ EXTERN enum {
|
|||||||
|
|
||||||
/* Flags for findcom()/comexec() */
|
/* Flags for findcom()/comexec() */
|
||||||
#define FC_SPECBI BIT(0) /* special builtin */
|
#define FC_SPECBI BIT(0) /* special builtin */
|
||||||
#define FC_FUNC BIT(1) /* function builtin */
|
#define FC_FUNC BIT(1) /* function */
|
||||||
#define FC_REGBI BIT(2) /* regular builtin */
|
#define FC_NORMBI BIT(2) /* not special builtin */
|
||||||
#define FC_UNREGBI BIT(3) /* un-regular builtin (!special,!regular) */
|
#define FC_BI (FC_SPECBI | FC_NORMBI)
|
||||||
#define FC_BI (FC_SPECBI|FC_REGBI|FC_UNREGBI)
|
#define FC_PATH BIT(3) /* do path search */
|
||||||
#define FC_PATH BIT(4) /* do path search */
|
#define FC_DEFPATH BIT(4) /* use default path in path search */
|
||||||
#define FC_DEFPATH BIT(5) /* use default path in path search */
|
|
||||||
|
|
||||||
|
|
||||||
#define AF_ARGV_ALLOC 0x1 /* argv[] array allocated */
|
#define AF_ARGV_ALLOC 0x1 /* argv[] array allocated */
|
||||||
|
6
syn.c
6
syn.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||||
* 2011, 2012
|
* 2011, 2012, 2013
|
||||||
* Thorsten Glaser <tg@mirbsd.org>
|
* Thorsten Glaser <tg@mirbsd.org>
|
||||||
*
|
*
|
||||||
* Provided that these terms and disclaimer and all copyright notices
|
* Provided that these terms and disclaimer and all copyright notices
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.89 2013/04/26 18:27:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.90 2013/04/26 21:22:50 tg Exp $");
|
||||||
|
|
||||||
struct nesting_state {
|
struct nesting_state {
|
||||||
int start_token; /* token than began nesting (eg, FOR) */
|
int start_token; /* token than began nesting (eg, FOR) */
|
||||||
@ -243,7 +243,7 @@ nested(int type, int smark, int emark)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char let_cmd[] = {
|
static const char let_cmd[] = {
|
||||||
CHAR, 'l', CHAR, 'e', CHAR, 't', EOS
|
CHAR, 'l', CHAR, 'e', CHAR, 't', CHAR, ']', EOS
|
||||||
};
|
};
|
||||||
static const char setA_cmd0[] = {
|
static const char setA_cmd0[] = {
|
||||||
CHAR, 's', CHAR, 'e', CHAR, 't', EOS
|
CHAR, 's', CHAR, 'e', CHAR, 't', EOS
|
||||||
|
Reference in New Issue
Block a user