diff --git a/BUILD.gn b/BUILD.gn index 391a1be..7bfe534 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -129,7 +129,8 @@ if (defined(ohos_lite)) { "-DHAVE_SYS_ERRLIST_DECL=1", "-DHAVE_SYS_SIGLIST_DECL=1", "-DHAVE_PERSISTENT_HISTORY=1", - "-DMKSH_BUILD_R=571", + "-DMKSH_UNLIMITED", + "-DMKSH_BUILD_R=593", ] ldflags = [ @@ -241,7 +242,8 @@ if (defined(ohos_lite)) { "-DHAVE_SYS_ERRLIST_DECL=1", "-DHAVE_SYS_SIGLIST_DECL=1", "-DHAVE_PERSISTENT_HISTORY=1", - "-DMKSH_BUILD_R=571", + "-DMKSH_UNLIMITED", + "-DMKSH_BUILD_R=593", ] ldflags = [ "-pie", diff --git a/Build.sh b/Build.sh index a77763c..f213cc0 100644 --- a/Build.sh +++ b/Build.sh @@ -1,8 +1,9 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.734 2019/03/01 16:18:13 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.763 2020/09/04 21:01:37 tg Exp $' #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012, 2013, 2014, 2015, 2016, 2017 +# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, +# 2020 # mirabilos # # Provided that these terms and disclaimer and all copyright notices @@ -25,8 +26,8 @@ srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.734 2019/03/01 16:18:13 tg Exp $' # # Used environment documentation is at the end of this file. -LC_ALL=C -export LC_ALL +LC_ALL=C; LANGUAGE=C +export LC_ALL; unset LANGUAGE case $ZSH_VERSION:$VERSION in :zsh*) ZSH_VERSION=2 ;; @@ -53,6 +54,15 @@ alll=qwertyuiopasdfghjklzxcvbnm alln=0123456789 alls=______________________________________________________________ +test_n() { + test x"$1" = x"" || return 0 + return 1 +} + +test_z() { + test x"$1" = x"" +} + case `echo a | tr '\201' X` in X) # EBCDIC build system @@ -64,11 +74,11 @@ X) esac genopt_die() { - if test -n "$1"; then - echo >&2 "E: $*" - echo >&2 "E: in '$srcfile': '$line'" - else + if test_z "$1"; then echo >&2 "E: invalid input in '$srcfile': '$line'" + else + echo >&2 "E: $*" + echo >&2 "N: in '$srcfile': '$line'" fi rm -f "$bn.gen" exit 1 @@ -172,9 +182,9 @@ do_genopt() { esac IFS= read line || genopt_die Unexpected EOF IFS=$safeIFS - test -n "$cond" && o_gen=$o_gen$nl"$cond" + test_z "$cond" || o_gen=$o_gen$nl"$cond" o_gen=$o_gen$nl"$line, $optc)" - test -n "$cond" && o_gen=$o_gen$nl"#endif" + test_z "$cond" || o_gen=$o_gen$nl"#endif" ;; esac done @@ -185,11 +195,11 @@ do_genopt() { esac echo "$o_str" | sort | while IFS='|' read x opts cond; do IFS=$safeIFS - test -n "$x" || continue + test_n "$x" || continue genopt_scond - test -n "$cond" && echo "$cond" + test_z "$cond" || echo "$cond" echo "\"$opts\"" - test -n "$cond" && echo "#endif" + test_z "$cond" || echo "#endif" done | { echo "$o_hdr" echo "#ifndef $o_sym$o_gen" @@ -234,7 +244,7 @@ vq() { rmf() { for _f in "$@"; do case $_f in - Build.sh|check.pl|check.t|dot.mkshrc|*.1|*.c|*.h|*.ico|*.opt) ;; + *.1|*.faq|*.ico) ;; *) rm -f "$_f" ;; esac done @@ -343,7 +353,7 @@ ac_testnnd() { test $ct = pcc && vscan='unsupported' test $ct = sunpro && vscan='-e ignored -e turned.off' fi - test -n "$vscan" && grep $vscan vv.out >/dev/null 2>&1 && fv=$fr + test_n "$vscan" && grep $vscan vv.out >/dev/null 2>&1 && fv=$fr return 0 } ac_testn() { @@ -406,10 +416,8 @@ ac_flags() { test x"$ft" = x"" && ft="if $f can be used" save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $f" - if test -n "$fl"; then - save_LDFLAGS=$LDFLAGS - LDFLAGS="$LDFLAGS $fl" - fi + save_LDFLAGS=$LDFLAGS + test_z "$fl" || LDFLAGS="$LDFLAGS $fl" if test 1 = $hf; then ac_testn can_$vn '' "$ft" else @@ -421,9 +429,7 @@ ac_flags() { #' fi eval fv=\$HAVE_CAN_`upper $vn` - if test -n "$fl"; then - test 11 = $fa$fv || LDFLAGS=$save_LDFLAGS - fi + test_z "$fl" || test 11 = $fa$fv || LDFLAGS=$save_LDFLAGS test 11 = $fa$fv || CFLAGS=$save_CFLAGS } @@ -512,7 +518,7 @@ ebcdic=false for i do case $last:$i in - c:combine|c:dragonegg|c:llvm|c:lto) + c:dragonegg|c:llvm) cm=$i last= ;; @@ -524,10 +530,6 @@ do optflags=$i last= ;; - t:*) - tfn=$i - last= - ;; :-c) last=c ;; @@ -573,9 +575,6 @@ do :+T) textmode=0 ;; - :-t) - last=t - ;; :-v) echo "Build.sh $srcversion" echo "for mksh $dstversion" @@ -591,12 +590,12 @@ do ;; esac done -if test -n "$last"; then +if test_n "$last"; then echo "$me: Option -'$last' not followed by argument!" >&2 exit 1 fi -test -z "$tfn" && if test $legacy = 0; then +test_n "$tfn" || if test $legacy = 0; then tfn=mksh else tfn=lksh @@ -606,7 +605,7 @@ if test -d $tfn || test -d $tfn.exe; then exit 1 fi rmf a.exe* a.out* conftest.c conftest.exe* *core core.* ${tfn}* *.bc *.dbg \ - *.ll *.o *.gen *.cat1 Rebuild.sh lft no signames.inc test.sh x vv.out + *.ll *.o *.gen *.cat1 Rebuild.sh lft no signames.inc test.sh x vv.out *.htm SRCS="lalloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c jobs.c" SRCS="$SRCS lex.c main.c misc.c shf.c syn.c tree.c var.c" @@ -634,17 +633,17 @@ if test x"$srcdir" = x"."; then else CPPFLAGS="-I. -I'$srcdir' $CPPFLAGS" fi -test -n "$LDSTATIC" && if test -n "$LDFLAGS"; then - LDFLAGS="$LDFLAGS $LDSTATIC" -else +test_z "$LDSTATIC" || if test_z "$LDFLAGS"; then LDFLAGS=$LDSTATIC +else + LDFLAGS="$LDFLAGS $LDSTATIC" fi -if test -z "$TARGET_OS"; then +if test_z "$TARGET_OS"; then x=`uname -s 2>/dev/null || uname` test x"$x" = x"`uname -n 2>/dev/null`" || TARGET_OS=$x fi -if test -z "$TARGET_OS"; then +if test_z "$TARGET_OS"; then echo "$me: Set TARGET_OS, your uname is broken!" >&2 exit 1 fi @@ -652,7 +651,7 @@ oswarn= ccpc=-Wc, ccpl=-Wl, tsts= -ccpr='|| for _f in ${tcfn}*; do case $_f in Build.sh|check.pl|check.t|dot.mkshrc|*.1|*.c|*.h|*.ico|*.opt) ;; *) rm -f "$_f" ;; esac; done' +ccpr='|| for _f in ${tcfn}*; do case $_f in *.1|*.faq|*.ico) ;; *) rm -f "$_f" ;; esac; done' # Evil hack if test x"$TARGET_OS" = x"Android"; then @@ -706,12 +705,12 @@ fi # Configuration depending on OS revision, on OSes that need them case $TARGET_OS in NEXTSTEP) - test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`hostinfo 2>&1 | \ + test_n "$TARGET_OSREV" || TARGET_OSREV=`hostinfo 2>&1 | \ grep 'NeXT Mach [0-9][0-9.]*:' | \ sed 's/^.*NeXT Mach \([0-9][0-9.]*\):.*$/\1/'` ;; QNX|SCO_SV) - test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`uname -r` + test_n "$TARGET_OSREV" || TARGET_OSREV=`uname -r` ;; esac @@ -722,6 +721,13 @@ case $TARGET_OS in add_cppflags -DMKSH_NO_SIGSETJMP add_cppflags -DMKSH_TYPEDEF_SIG_ATOMIC_T=int ;; +A/UX) + add_cppflags -D_POSIX_SOURCE + : "${CC=gcc}" + : "${LIBS=-lposix}" + # GCC defines AUX but cc nothing + add_cppflags -D__A_UX__ + ;; AIX) add_cppflags -D_ALL_SOURCE : "${HAVE_SETLOCALE_CTYPE=0}" @@ -799,6 +805,7 @@ OpenHarmony) : "${MKSH_SMALL_BUT_FAST=0}" : "${MKSH_ASSUME_UTF8=1}" : "${MKSH_S_NOVI=1}" + : "${MKSH_UNLIMITED=1}" ;; Harvey) add_cppflags -D_POSIX_SOURCE @@ -859,6 +866,11 @@ Linux) LynxOS) oswarn="; it has minor issues" ;; +midipix) + add_cppflags -D_GNU_SOURCE + # their Perl (currently…) identifies as os:linux ☹ + check_categories="$check_categories os:midipix" + ;; MidnightBSD) ;; Minix-vmd) @@ -870,10 +882,9 @@ Minix-vmd) ;; Minix3) add_cppflags -DMKSH_UNEMPLOYED - add_cppflags -DMKSH_NO_LIMITS add_cppflags -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 -D_MINIX oldish_ed=no-stderr-ed # /usr/bin/ed(!) is broken - : "${HAVE_SETLOCALE_CTYPE=0}" + : "${HAVE_SETLOCALE_CTYPE=0}${MKSH_UNLIMITED=1}" #XXX recheck ulimit ;; MirBSD) ;; @@ -906,7 +917,7 @@ NEXTSTEP) Ninix3) # similar to Minix3 add_cppflags -DMKSH_UNEMPLOYED - add_cppflags -DMKSH_NO_LIMITS + : "${MKSH_UNLIMITED=1}" #XXX recheck ulimit # but no idea what else could be needed oswarn="; it has unknown issues" ;; @@ -919,15 +930,14 @@ OS/2) HAVE_ISOFF_MKSH_ASSUME_UTF8=1 HAVE_TERMIOS_H=0 HAVE_MKNOD=0 # setmode() incompatible - oswarn="; it is being ported" check_categories="$check_categories nosymlink" : "${CC=gcc}" : "${SIZE=: size}" SRCS="$SRCS os2.c" add_cppflags -DMKSH_UNEMPLOYED add_cppflags -DMKSH_NOPROSPECTOFWORK - add_cppflags -DMKSH_NO_LIMITS add_cppflags -DMKSH_DOSPATH + : "${MKSH_UNLIMITED=1}" if test $textmode = 0; then x='dis' y='standard OS/2 tools' @@ -1049,11 +1059,11 @@ _svr4) # generic target for SVR4 Unix with uname -s = uname -n # this duplicates the * target below oswarn='; it may or may not work' - test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`uname -r` + test_n "$TARGET_OSREV" || TARGET_OSREV=`uname -r` ;; *) oswarn='; it may or may not work' - test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`uname -r` + test_n "$TARGET_OSREV" || TARGET_OSREV=`uname -r` ;; esac @@ -1096,11 +1106,12 @@ SCO_SV|UnixWare|UNIX_SV) vv '|' "uname -a >&2" ;; esac -test -z "$oswarn" || echo >&2 " +test_z "$oswarn" || echo >&2 " Warning: mksh has not yet been ported to or tested on your operating system '$TARGET_OS'$oswarn. If you can provide a shell account to the developer, this may improve; please -drop us a success or failure notice or even send in diffs. +drop us a success or failure notice or even send in diffs, +at the very least, complete logs (Build.sh + test.sh) will help. " $e "$bi$me: Building the MirBSD Korn Shell$ao $ui$dstversion$ao on $TARGET_OS ${TARGET_OSREV}..." @@ -1127,6 +1138,10 @@ ct="icc" ct="xlc" #elif defined(__SUNPRO_C) ct="sunpro" +#elif defined(__neatcc__) +ct="neatcc" +#elif defined(__lacc__) +ct="lacc" #elif defined(__ACK__) ct="ack" #elif defined(__BORLANDC__) @@ -1242,9 +1257,8 @@ dmc) ;; gcc) vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS" - vv '|' 'echo `$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS \ - -dumpmachine` gcc`$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN \ - $LIBS -dumpversion`' + vv '|' 'eval echo "\`$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -dumpmachine\`" \ + "gcc\`$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -dumpversion\`"' : "${HAVE_STRING_POOLING=i2}" ;; hpcc) @@ -1262,6 +1276,9 @@ icc) kencc) vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS" ;; +lacc) + # no version information + ;; lcc) vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS" add_cppflags -D__inline__=__inline @@ -1278,21 +1295,27 @@ msc) ccpr= # errorlevels are not reliable case $TARGET_OS in Interix) - if [[ -n $C89_COMPILER ]]; then - C89_COMPILER=`ntpath2posix -c "$C89_COMPILER"` - else + if test_z "$C89_COMPILER"; then C89_COMPILER=CL.EXE - fi - if [[ -n $C89_LINKER ]]; then - C89_LINKER=`ntpath2posix -c "$C89_LINKER"` else + C89_COMPILER=`ntpath2posix -c "$C89_COMPILER"` + fi + if test_z "$C89_LINKER"; then C89_LINKER=LINK.EXE + else + C89_LINKER=`ntpath2posix -c "$C89_LINKER"` fi vv '|' "$C89_COMPILER /HELP >&2" vv '|' "$C89_LINKER /LINK >&2" ;; esac ;; +neatcc) + add_cppflags -DMKSH_DONT_EMIT_IDSTRING + add_cppflags -DMKSH_NO_SIGSETJMP + add_cppflags -Dsig_atomic_t=int + vv '|' "$CC" + ;; nwcc) vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -version" ;; @@ -1345,7 +1368,7 @@ xlc) *) test x"$ct" = x"untested" && $e "!!! detecting preprocessor failed" ct=unknown - vv "$CC --version" + vv '|' "$CC --version" vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS" vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -V conftest.c $LIBS" ;; @@ -1358,7 +1381,7 @@ esac etd=" on $et" case $et in klibc) - add_cppflags -DMKSH_NO_LIMITS + : "${MKSH_UNLIMITED=1}" ;; unknown) # nothing special detected, don’t worry @@ -1388,14 +1411,14 @@ if ac_ifcpp 'if 0' compiler_fails '' \ case $ct in dec) CFLAGS="$CFLAGS ${ccpl}-non_shared" - ac_testn can_delexe compiler_fails 0 'for the -non_shared linker option' <<-EOF + ac_testn can_delexe compiler_fails 0 'for the -non_shared linker option' <<-'EOF' #include int main(void) { return (isatty(0)); } EOF ;; dmc) CFLAGS="$CFLAGS ${ccpl}/DELEXECUTABLE" - ac_testn can_delexe compiler_fails 0 'for the /DELEXECUTABLE linker option' <<-EOF + ac_testn can_delexe compiler_fails 0 'for the /DELEXECUTABLE linker option' <<-'EOF' #include int main(void) { return (isatty(0)); } EOF @@ -1405,9 +1428,8 @@ if ac_ifcpp 'if 0' compiler_fails '' \ ;; esac test 1 = $HAVE_CAN_DELEXE || CFLAGS=$save_CFLAGS - ac_testn compiler_still_fails '' 'if the compiler still does not fail correctly' <<-EOF - EOF - test 1 = $HAVE_COMPILER_STILL_FAILS && exit 1 + ac_ifcpp 'if 0' compiler_still_fails \ + 'if the compiler still does not fail correctly' && exit 1 fi if ac_ifcpp 'ifdef __TINYC__' couldbe_tcc '!' compiler_known 0 \ 'if this could be tcc'; then @@ -1490,7 +1512,7 @@ NOWARN=$save_NOWARN # i=`echo :"$orig_CFLAGS" | sed 's/^://' | tr -c -d $alll$allu$alln` # optimisation: only if orig_CFLAGS is empty -test x"$i" = x"" && case $ct in +test_n "$i" || case $ct in hpcc) phase=u ac_flags 1 otwo +O2 @@ -1538,6 +1560,7 @@ dmc) ac_flags 1 schk "${ccpc}-s" 'for stack overflow checking' ;; gcc) + ac_flags 1 fnolto -fno-lto 'whether we can explicitly disable buggy GCC LTO' -fno-lto # The following tests run with -Werror (gcc only) if possible NOWARN=$DOWARN; phase=u ac_flags 1 wnodeprecateddecls -Wno-deprecated-declarations @@ -1720,7 +1743,7 @@ ac_test attribute_format '' 'for __attribute__((__format__))' <<-'EOF' #undef fprintf extern int fprintf(FILE *, const char *format, ...) __attribute__((__format__(__printf__, 2, 3))); - int main(int ac, char **av) { return (fprintf(stderr, "%s%d", *av, ac)); } + int main(int ac, char *av[]) { return (fprintf(stderr, "%s%d", *av, ac)); } #endif EOF ac_test attribute_noreturn '' 'for __attribute__((__noreturn__))' <<-'EOF' @@ -1745,7 +1768,7 @@ ac_test attribute_pure '' 'for __attribute__((__pure__))' <<-'EOF' #include #undef __attribute__ int foo(const char *) __attribute__((__pure__)); - int main(int ac, char **av) { return (foo(av[ac - 1]) + isatty(0)); } + int main(int ac, char *av[]) { return (foo(av[ac - 1]) + isatty(0)); } int foo(const char *s) { return ((int)s[0]); } #endif EOF @@ -1757,7 +1780,7 @@ ac_test attribute_unused '' 'for __attribute__((__unused__))' <<-'EOF' #else #include #undef __attribute__ - int main(int ac __attribute__((__unused__)), char **av + int main(int ac __attribute__((__unused__)), char *av[] __attribute__((__unused__))) { return (isatty(0)); } #endif EOF @@ -1875,39 +1898,22 @@ rmf lft* # end of large file support test ac_test can_inttypes '!' stdint_h 1 "for standard 32-bit integer types" <<-'EOF' #include #include - int main(int ac, char **av) { return ((uint32_t)(size_t)*av + (int32_t)ac); } + int main(int ac, char *av[]) { return ((uint32_t)(size_t)*av + (int32_t)ac); } EOF ac_test can_ucbints '!' can_inttypes 1 "for UCB 32-bit integer types" <<-'EOF' #include #include - int main(int ac, char **av) { return ((u_int32_t)(size_t)*av + (int32_t)ac); } + int main(int ac, char *av[]) { return ((u_int32_t)(size_t)*av + (int32_t)ac); } EOF ac_test can_int8type '!' stdint_h 1 "for standard 8-bit integer type" <<-'EOF' #include #include - int main(int ac, char **av) { return ((uint8_t)(size_t)av[ac]); } + int main(int ac, char *av[]) { return ((uint8_t)(size_t)av[ac]); } EOF ac_test can_ucbint8 '!' can_int8type 1 "for UCB 8-bit integer type" <<-'EOF' #include #include - int main(int ac, char **av) { return ((u_int8_t)(size_t)av[ac]); } -EOF - -ac_test rlim_t <<-'EOF' - #include - #if HAVE_BOTH_TIME_H - #include - #include - #elif HAVE_SYS_TIME_H - #include - #elif HAVE_TIME_H - #include - #endif - #if HAVE_SYS_RESOURCE_H - #include - #endif - #include - int main(void) { return (((int)(rlim_t)0) + isatty(0)); } + int main(int ac, char *av[]) { return ((u_int8_t)(size_t)av[ac]); } EOF # only testn: added later below @@ -1960,7 +1966,11 @@ else #define MKSH_INCLUDES_ONLY #include "sh.h" __RCSID("$srcversion"); - int main(void) { printf("Hello, World!\\n"); return (isatty(0)); } + int main(void) { + struct timeval tv; + printf("Hello, World!\\n"); + return (time(&tv.tv_sec)); + } EOF case $cm in llvm) @@ -2017,15 +2027,15 @@ ac_cppflags SYS_ERRLIST for what in name list; do uwhat=`upper $what` - ac_testn sys_sig$what '' "the sys_sig${what}[] array" <<-EOF - extern const char * const sys_sig${what}[]; + ac_testn sys_sig$what '' "the sys_sig$what[] array" <<-EOF + extern const char * const sys_sig$what[]; extern int isatty(int); - int main(void) { return (sys_sig${what}[0][0] + isatty(0)); } + int main(void) { return (sys_sig$what[0][0] + isatty(0)); } EOF - ac_testn _sys_sig$what '!' sys_sig$what 0 "the _sys_sig${what}[] array" <<-EOF - extern const char * const _sys_sig${what}[]; + ac_testn _sys_sig$what '!' sys_sig$what 0 "the _sys_sig$what[] array" <<-EOF + extern const char * const _sys_sig$what[]; extern int isatty(int); - int main(void) { return (_sys_sig${what}[0][0] + isatty(0)); } + int main(void) { return (_sys_sig$what[0][0] + isatty(0)); } EOF eval uwhat_v=\$HAVE__SYS_SIG$uwhat if test 1 = "$uwhat_v"; then @@ -2058,6 +2068,35 @@ ac_test lock_fcntl '!' flock 1 'whether we can lock files with fcntl' <<-'EOF' } EOF +ac_test rlimit '' 'getrlimit and setrlimit' <<-'EOF' + #define MKSH_INCLUDES_ONLY + #include "sh.h" + int main(void) { + struct rlimit l; + if (getrlimit(0, &l)) return 1; + l.rlim_max = l.rlim_cur; + l.rlim_cur = RLIM_INFINITY; + return (setrlimit(0, &l)); + } +EOF + +ac_test rlim_t rlimit 0 <<-'EOF' + #include + #if HAVE_BOTH_TIME_H + #include + #include + #elif HAVE_SYS_TIME_H + #include + #elif HAVE_TIME_H + #include + #endif + #if HAVE_SYS_RESOURCE_H + #include + #endif + #include + int main(void) { return (((int)(rlim_t)0) + isatty(0)); } +EOF + ac_test getrusage <<-'EOF' #define MKSH_INCLUDES_ONLY #include "sh.h" @@ -2277,6 +2316,17 @@ ac_test sys_siglist_decl sys_siglist 0 'for declaration of sys_siglist[]' <<-'EO int main(void) { return (sys_siglist[0][0] + isatty(0)); } EOF +ac_test st_mtim '' 'for struct stat.st_mtim.tv_nsec' <<-'EOF' + #define MKSH_INCLUDES_ONLY + #include "sh.h" + int main(void) { struct stat sb; return (sizeof(sb.st_mtim.tv_nsec)); } +EOF +ac_test st_mtimensec '!' st_mtim 0 'for struct stat.st_mtimensec' <<-'EOF' + #define MKSH_INCLUDES_ONLY + #include "sh.h" + int main(void) { struct stat sb; return (sizeof(sb.st_mtimensec)); } +EOF + # # other checks # @@ -2299,7 +2349,7 @@ if test $legacy = 1; then #define CHAR_BIT 0 #endif struct ctasserts { - #define cta(name, assertion) char name[(assertion) ? 1 : -1] + #define cta(name,assertion) char name[(assertion) ? 1 : -1] cta(char_is_8_bits, (CHAR_BIT) == 8); cta(long_is_32_bits, sizeof(long) == 4); }; @@ -2313,7 +2363,7 @@ EOF #define CHAR_BIT 0 #endif struct ctasserts { - #define cta(name, assertion) char name[(assertion) ? 1 : -1] + #define cta(name,assertion) char name[(assertion) ? 1 : -1] cta(char_is_8_bits, (CHAR_BIT) == 8); cta(long_is_64_bits, sizeof(long) == 8); }; @@ -2437,11 +2487,24 @@ mksh_cfg= cfg_NSIG $e done. fi +if test 1 = "$MKSH_UNLIMITED"; then + add_cppflags -DMKSH_UNLIMITED +else + MKSH_UNLIMITED=0 +fi + +if test 1 = "$USE_PRINTF_BUILTIN"; then + add_cppflags -DMKSH_PRINTF_BUILTIN +else + USE_PRINTF_BUILTIN=0 +fi + addsrcs '!' HAVE_STRLCPY strlcpy.c addsrcs USE_PRINTF_BUILTIN printf.c -test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN +addsrcs '!' MKSH_UNLIMITED ulimit.c + test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose" -add_cppflags -DMKSH_BUILD_R=571 +add_cppflags -DMKSH_BUILD_R=593 $e $bi$me: Finished configuration testing, now producing output.$ao @@ -2464,7 +2527,10 @@ esac cat >test.sh <<-EOF $mkshshebang LC_ALL=C PATH='$PATH'; export LC_ALL PATH - test -n "\$KSH_VERSION" || exit 1 + case \$KSH_VERSION in + *MIRBSD*|*LEGACY*) ;; + *) exit 1 ;; + esac set -A check_categories -- $check_categories pflag='$curdir/$mkshexe' sflag='$srcdir/check.t' @@ -2521,7 +2587,7 @@ cat >test.sh <<-EOF args[\${#args[*]}]=\$TMPDIR fi print Testing mksh for conformance: - grep -F -e Mir''OS: -e MIRBSD "\$sflag" + grep -F -e 'KSH R' -e Mir''OS: "\$sflag" | sed '/KSH/s/^./& /' print "This shell is actually:\\n\\t\$KSH_VERSION" print 'test.sh built for mksh $dstversion' cstr='\$os = defined \$^O ? \$^O : "unknown";' @@ -2581,7 +2647,6 @@ for file in $SRCS; do op=`echo x"$file" | sed 's/^x\(.*\)\.c$/\1./'` test -f $file || file=$srcdir/$file files="$files$sp$file" - sp=' ' echo "$CC $CFLAGS $CPPFLAGS $emitbc $file || exit 1" >>Rebuild.sh if test $cm = dragonegg; then echo "mv ${op}s ${op}ll" >>Rebuild.sh @@ -2590,6 +2655,7 @@ for file in $SRCS; do else objs="$objs$sp${op}o" fi + sp=' ' done case $cm in dragonegg|llvm) @@ -2605,7 +2671,7 @@ echo tcfn=$mkshexe >>Rebuild.sh echo "$CC $CFLAGS $LDFLAGS -o \$tcfn $lobjs $LIBS $ccpr" >>Rebuild.sh echo "test -f \$tcfn || exit 1; $SIZE \$tcfn" >>Rebuild.sh if test $cm = makefile; then - extras='emacsfn.h exprtok.h rlimits.opt sh.h sh_flags.opt var_spec.h' + extras='emacsfn.h exprtok.h rlimits.opt sh.h sh_flags.opt ulimits.opt var_spec.h' test 0 = $HAVE_SYS_SIGNAME && extras="$extras signames.inc" gens= genq= for file in $optfiles; do @@ -2626,8 +2692,8 @@ INDSRCS= $extras NONSRCS_INST= dot.mkshrc \$(MAN) NONSRCS_NOINST= Build.sh Makefile Rebuild.sh check.pl check.t test.sh CC= $CC -CFLAGS= $CFLAGS CPPFLAGS= $CPPFLAGS +CFLAGS= $CFLAGS LDFLAGS= $LDFLAGS LIBS= $LIBS @@ -2697,6 +2763,7 @@ test $cm = combine || v "$CC $CFLAGS $LDFLAGS -o $tcfn $lobjs $LIBS $ccpr" test -f $tcfn || exit 1 test 1 = $r || v "$NROFF -mdoc <'$srcdir/lksh.1' >lksh.cat1" || rmf lksh.cat1 test 1 = $r || v "$NROFF -mdoc <'$srcdir/mksh.1' >mksh.cat1" || rmf mksh.cat1 +test 1 = $r || v "(set -- ''; . '$srcdir/FAQ2HTML.sh')" || rmf FAQ.htm test 0 = $eq && v $SIZE $tcfn i=install test -f /usr/ucb/$i && i=/usr/ucb/$i @@ -2710,7 +2777,13 @@ if test $legacy = 0; then fi $e $e Installing the manual: +if test -f FAQ.htm; then + $e "# $i -c -o root -g bin -m 444 FAQ.htm /usr/share/doc/mksh/" +fi if test -f mksh.cat1; then + if test -f FAQ.htm; then + $e plus either + fi $e "# $i -c -o root -g bin -m 444 lksh.cat1" \ "/usr/share/man/cat1/lksh.0" $e "# $i -c -o root -g bin -m 444 mksh.cat1" \ @@ -2721,6 +2794,8 @@ $e "# $i -c -o root -g bin -m 444 lksh.1 mksh.1 /usr/share/man/man1/" $e $e Run the regression test suite: ./test.sh $e Please also read the sample file dot.mkshrc and the fine manual. +test -f FAQ.htm || \ + $e Run FAQ2HTML.sh and place FAQ.htm into a suitable location as well. exit 0 : <<'EOD' @@ -2743,6 +2818,7 @@ TARGET_OS default: $(uname -s || uname) TARGET_OSREV [QNX] default: $(uname -r) ==== feature selectors ==== +MKSH_UNLIMITED 1 to omit ulimit builtin completely USE_PRINTF_BUILTIN 1 to include (unsupported) printf(1) as builtin ===== general format ===== HAVE_STRLEN ac_test @@ -2750,8 +2826,9 @@ HAVE_STRING_H ac_header HAVE_CAN_FSTACKPROTECTORALL ac_flags ==== cpp definitions ==== -DEBUG dont use in production, wants gcc, implies: +DEBUG don’t use in production, wants gcc, implies: DEBUG_LEAKS enable freeing resources before exiting +KSH_VERSIONNAME_VENDOR_EXT when patching; space+plus+word (e.g. " +SuSE") MKSHRC_PATH "~/.mkshrc" (do not change) MKSH_A4PB force use of arc4random_pushb MKSH_ASSUME_UTF8 (0=disabled, 1=enabled; default: unset) @@ -2771,7 +2848,6 @@ MKSH_NOPROSPECTOFWORK disable jobs, co-processes, etc. (do not use) MKSH_NOPWNAM skip PAM calls, for -static on glibc or Solaris MKSH_NO_CMDLINE_EDITING disable command line editing code entirely MKSH_NO_DEPRECATED_WARNING omit warning when deprecated stuff is run -MKSH_NO_LIMITS omit ulimit code MKSH_NO_SIGSETJMP define if sigsetjmp is broken or not available MKSH_NO_SIGSUSPEND use sigprocmask+pause instead of sigsuspend MKSH_SMALL omit some code, optimise hard for size (slower) @@ -2780,6 +2856,7 @@ MKSH_S_NOVI=1 disable Vi editing mode (default if MKSH_SMALL) MKSH_TYPEDEF_SIG_ATOMIC_T define to e.g. 'int' if sig_atomic_t is missing MKSH_TYPEDEF_SSIZE_T define to e.g. 'long' if your OS has no ssize_t MKSH_UNEMPLOYED disable job control (but not jobs/co-processes) +USE_REALLOC_MALLOC define as 0 to not use realloc as malloc === generic installation instructions === @@ -2789,15 +2866,15 @@ them, set to a value other than 0 or 1. Ensure /bin/ed is installed. For MKSH_SMALL but with Vi mode, add -DMKSH_S_NOVI=0 to CPPFLAGS as well. Normally, the following command is what you want to run, then: -$ (sh Build.sh -r -c lto && ./test.sh -f) 2>&1 | tee log +$ (sh Build.sh -r && ./test.sh -f) 2>&1 | tee log Copy dot.mkshrc to /etc/skel/.mkshrc; install mksh into $prefix/bin; or /bin; install the manpage, if omitting the -r flag a catmanpage is made using $NROFF. Consider using a forward script as /etc/skel/.mkshrc like -http://anonscm.debian.org/cgit/collab-maint/mksh.git/plain/debian/.mkshrc +https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=alioth/mksh.git;a=blob;f=debian/.mkshrc and put dot.mkshrc as /etc/mkshrc so users need not keep up their HOME. You may also want to install the lksh binary (also as /bin/sh) built by: -$ CPPFLAGS="$CPPFLAGS -DMKSH_BINSHPOSIX" sh Build.sh -L -r -c lto +$ CPPFLAGS="$CPPFLAGS -DMKSH_BINSHPOSIX" sh Build.sh -L -r EOD diff --git a/COPYRIGHT b/COPYRIGHT index 0a16169..f0e7ec6 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -26,3 +26,7 @@ Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2018 2011, 2012, 2013, 2015, 2016, 2017 Copyright (c) 2009, 2011, 2012, 2016, 2018 +Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, +2019, 2020 +mirabilos \ No newline at end of file diff --git a/FAQ2HTML.sh b/FAQ2HTML.sh new file mode 100644 index 0000000..ecff077 --- /dev/null +++ b/FAQ2HTML.sh @@ -0,0 +1,136 @@ +#!/bin/sh +rcsid='$MirOS: src/bin/mksh/FAQ2HTML.sh,v 1.2 2020/10/31 04:17:36 tg Exp $' +#- +# Copyright © 2020 +# mirabilos +# +# Provided that these terms and disclaimer and all copyright notices +# are retained or reproduced in an accompanying document, permission +# is granted to deal in this work without restriction, including un‐ +# limited rights to use, publicly perform, distribute, sell, modify, +# merge, give away, or sublicence. +# +# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to +# the utmost extent permitted by applicable law, neither express nor +# implied; without malicious intent or gross negligence. In no event +# may a licensor, author or contributor be held liable for indirect, +# direct, other damage, loss, or other issues arising in any way out +# of dealing in the work, even if advised of the possibility of such +# damage or existence of a defect, except proven that it results out +# of said person’s immediate fault when using the work as intended. +#- + +set -e +LC_ALL=C; LANGUAGE=C +export LC_ALL; unset LANGUAGE +nl=' +' +srcdir=$(dirname "$0") + +p=--posix +sed $p -e q /dev/null 2>&1 || p= + +v=$1 +if test -z "$v"; then + v=$(sed $p -n '/^#define MKSH_VERSION "\(.*\)"$/s//\1/p' "$srcdir"/sh.h) +fi +src_id=$(sed $p -n '/^RCSID: /s///p' "$srcdir"/mksh.faq) +# sanity check +case $src_id in +*"$nl"*) + echo >&2 "E: more than one RCSID in mksh.faq?" + exit 1 ;; +esac + +sed $p \ + -e '/^RCSID: \$/s/^.*$/----/' \ + -e 's!@@RELPATH@@!http://www.mirbsd.org/!g' \ + -e 's^  ' \ + "$srcdir"/mksh.faq | tr '\n' '' | sed $p \ + -e 'sg' \ + -e 's----g' \ + -e 's\([^]*\)\1g' \ + -e 's\([^]*\)\1g' \ + -e 's\([^]*\)*ToC: \([^]*\)Title: \([^]*\)\([^]*\)\{0,1\}

\3


g' \ + -e 's[^]*

g' \ + -e 's^
*' \ + -e 's$' \ + -e 's<><>g' \ + -e 'sg' | tr '' '\n' >FAQ.tmp + +exec >FAQ.htm~ +cat < + + + mksh $v FAQ (local copy) + + + + +

Note: Links marked like this + one to the mksh IRC channel connect to external resources.

+

Notice: the website will have the latest version of the + mksh FAQ online.

+

Table of Contents

+