Additional documentation and examples
=====================================

Please read the links on http://www.mirbsd.org/ksh-chan.htm and peek at:
https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=shellsnippets/shellsnippets.git

Check the local FAQ at: file:///usr/share/doc/mksh/FAQ.htm


Reporting bugs
==============

Please report only packaging and, if you must, code bugs in
the Debian BTS. Please refrain from reporting feature requests
in the Debian BTS; directly submit those upstream it possible,
they may be ignored and closed if reported as Debian bugs. The
contact info for upstream is:

* #!/bin/mksh IRC channel
  at irc.oftc.net (Port 6697 SSL, 6667 unencrypted) currently

* via Fediverse (see FAQ.htm)

* https://launchpad.net/mksh


Notes for the mksh binary package
=================================

* After installation, it is strongly recommended to copy the file
  /etc/skel/.mkshrc into your home directory to get a nicer prompt,
  pushd/popd/dirs/setenv/enable functionality, some aliases, etc.
  (you can then customise it; reading the manual page also often
  helps). Note that /etc/skel/.mkshrc sources /etc/mkshrc (which
  is the upstream-provided file) by default and contains some more
  (commented out) examples to set the locale and editor, etc. Change
  the file to suit your needs once copied into your home directory.

* The MirBSD Korn Shell provides a workable /bin/sh for Debian;
  installation however is not automatic due to Debian #540512 (a
  wontfix RC bug in dash). It is strongly recommended to use its
  “legacy” flavour for this, as it uses the host “long” C type for
  integer arithmetic operations, enables POSIX mode if called as
  /bin/sh, and contains some workarounds for broken Debian maintainer
  scripts. First dpkg-reconfigure -plow dash to disable it sitting on
  /bin/sh, then use these commands:
  $ sudo ln -sf lksh /bin/sh
  $ sudo ln -sf lksh.1.gz /usr/share/man/man1/sh.1.gz
  Please note that lksh, as opposed to mksh, is not well-suited for
  interactive use (but no regression from dash which also isn’t).

* The /bin/lksh binary is used to run legacy ksh88 and pdksh scripts.
  It is not intended for interactive use, but has a printf(1) builtin.
  It is, however, usable as /bin/sh on Debian systems. In contrast,
  /bin/mksh-static should be used on initrd/initramfs as shell.

* /bin/mksh is built with the following options:
  - extra hardening flags: +all
  - glibc (dynamically linked)

* /bin/mksh-static is built with the following options:
  - extra hardening flags: +all but no PIE
    (position independent code), as this is a static executable
  - glibc, if cross-built or running the testsuite is disabled;
    otherwise klibc if available and working, otherwise musl if
    available and working, otherwise dietlibc if available and
    working, otherwise glibc (statically linked)
  - symbolic link, unless built against glibc
  - note that the stack protector is disabled on dietlibc, klibc
    due to limitations in those operating environments
  - calling as sh or -sh invokes "set -o posix -o sh"
  - -DMKSH_SMALL -DMKSH_SMALL_BUT_FAST
  - no locale support; uses getenv on LANG/LC_CTYPE/LC_ALL

* /usr/lib/diet/bin/mksh is a symlink target for /bin/mksh-static
  - only built if not a cross-build, dietlibc is enabled and successful

* /usr/lib/klibc/bin/mksh is a symlink target for /bin/mksh-static
  - only built if not a cross-build, klibc is enabled and successful

* /usr/lib/*musl*/bin/mksh is a symlink target for /bin/mksh-static
  - only built if not a cross-build, musl is enabled and successful

* /usr/lib/<MA>/bin/mksh is a symlink target for /bin/mksh-static
  – if the other three are not used (e.g. for the Hurd)

* /bin/lksh is built with the following options:
  - extra hardening flags: +all (no PIE if statically linked)
  - dietlibc, klibc, or musl (statically linked), or glibc
    (dynamically linked), under similar rules as /bin/mksh-static
  - the printf builtin
  - calling as sh or -sh invokes "set -o posix -o sh"
  - no locale support; uses getenv on LANG/LC_CTYPE/LC_ALL

Details (generated during package build) can be found below:

This build needs at least Linux 5.1 for klibc-built binaries.

Build information for mksh R59c-41:
| DEB_BUILD_GNU_TYPE='aarch64-linux-gnu'
| DEB_HOST_GNU_TYPE='aarch64-linux-gnu'
| DEB_BUILD_OPTIONS_reproducible=''
----
Build information for full mksh
set -A check_categories --  shell:legacy-no int:32 shell:textmode-no shell:binmode-yes stdout-ed no-stderr-ed have:select:1
gcc (Ubuntu 14.2.0-19ubuntu2) 14.2.0
Result: regressed (broken<failed<firstbuilt<checked<unattended<regressed)
Variables used:
| CC='gcc'
| CFLAGS='-g -O2 -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra'
| CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT'
| LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed'
| LDSTATIC=''
| LIBS=''
Actual compilation options:
] gcc -g -O2 -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fstack-protector-strong -fwrapv  -I. -I'../..' -Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT -DMKSH_BUILDSH=1 -D_GNU_SOURCE -DSETUID_CAN_FAIL_WITH_EAGAIN=1 -DHAVE_STRING_POOLING=2 -DHAVE_ATTRIBUTE_BOUNDED=0 -DHAVE_ATTRIBUTE_FORMAT=1 -DHAVE_ATTRIBUTE_NORETURN=1 -DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_TIME_H=1 -DHAVE_TIME_H=1 -DHAVE_BOTH_TIME_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SELECT_TIME_H=1 -DHAVE_SYS_BSDTYPES_H=0 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_PTEM_H=0 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_SYS_SYSMACROS_H=1 -DHAVE_BSTRING_H=0 -DHAVE_GRP_H=1 -DHAVE_IO_H=0 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 -DHAVE_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_ULIMIT_H=1 -DHAVE_CAN_INTTYPES=1 -DHAVE_SIG_T=1 -DHAVE_STRERRORDESC_NP=1 -DHAVE_SYS_ERRLIST=0 -DHAVE_SIGABBREV_NP=1 -DHAVE_SYS_SIGNAME=0 -DHAVE_SIGDESCR_NP=1 -DHAVE_SYS_SIGLIST=0 -DHAVE_FLOCK=1 -DHAVE_LOCK_FCNTL=1 -DHAVE_RLIMIT=1 -DHAVE_GET_CURRENT_DIR_NAME=1 -DHAVE_GETRANDOM=1 -DHAVE_GETRUSAGE=1 -DHAVE_GETSID=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_KILLPG=1 -DHAVE_MEMMOVE=1 -DHAVE_MKNOD=0 -DHAVE_MMAP=1 -DHAVE_FTRUNCATE=1 -DHAVE_NICE=1 -DHAVE_RENAME=1 -DHAVE_REVOKE=0 -DHAVE_POSIX_UTF8_LOCALE=1 -DHAVE_SELECT=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_SIGACTION=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 -DHAVE_STRLCPY=1 -DHAVE_STRSTR=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_ERRLIST_DECL=0 -DHAVE_SYS_SIGLIST_DECL=0 -Dst_mtimensec=st_mtim.tv_nsec -DHAVE_ST_MTIMENSEC=1 -DHAVE_INTCONSTEXPR_RSIZE_MAX=0 -DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=599 -c ../../main.c || exit 1
] gcc -g -O2 -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fstack-protector-strong -fwrapv  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -fno-lto -o $tcfn lalloc.o edit.o eval.o exec.o expr.o funcs.o histrap.o jobs.o lex.o main.o misc.o shf.o syn.o tree.o var.o ulimit.o  || for _f in ${tcfn}*; do case $_f in lksh.1|mksh.1|mksh.faq|mksh.ico) ;; *) rm -f "$_f" ;; esac; done
Resulting binary:
|    text	   data	    bss	    dec	    hex	filename
|  334989	   6720	   7856	 349565	  5557d	builddir/full/mksh
----
Build information for static-dietlibc mksh
set -A check_categories --  shell:legacy-no int:32 shell:textmode-no shell:binmode-yes smksh binsh no-histfile stdout-ed no-stderr-ed have:select:1
gcc -nostdlib -static -L/usr/lib/aarch64-linux-gnu/diet/lib-aarch64 -L/usr/lib/diet/lib /usr/lib/aarch64-linux-gnu/diet/lib-aarch64/start.o --version -isystem /usr/lib/aarch64-linux-gnu/diet/include -D__dietlibc__ -D_DISTRO_EVADE_TIME_BITS -Os -fomit-frame-pointer /usr/lib/aarch64-linux-gnu/diet/lib-aarch64/libc.a -lgcc 
gcc (Ubuntu 14.2.0-19ubuntu2) 14.2.0
Result: regressed (broken<failed<firstbuilt<checked<unattended<regressed)
Variables used:
| CC='diet -v -Os gcc'
| CFLAGS='-g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra'
| CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED -DMKSH_SMALL -DMKSH_SMALL_BUT_FAST'
| LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed'
| LDSTATIC=' '
| LIBS=''
Actual compilation options:
] diet -v -Os gcc -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fstack-protector-strong -fwrapv  -I. -I'../..' -Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED -DMKSH_SMALL -DMKSH_SMALL_BUT_FAST -DMKSH_BUILDSH=1 -D_GNU_SOURCE -DSETUID_CAN_FAIL_WITH_EAGAIN=1 -D_BSD_SOURCE -DHAVE_STRING_POOLING=2 -DHAVE_ATTRIBUTE_BOUNDED=0 -DHAVE_ATTRIBUTE_FORMAT=1 -DHAVE_ATTRIBUTE_NORETURN=1 -DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_TIME_H=1 -DHAVE_TIME_H=1 -DHAVE_BOTH_TIME_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SELECT_TIME_H=1 -DHAVE_SYS_BSDTYPES_H=0 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_PTEM_H=0 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_SYS_SYSMACROS_H=1 -DHAVE_BSTRING_H=0 -DHAVE_GRP_H=1 -DHAVE_IO_H=0 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 -DHAVE_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_ULIMIT_H=1 -DHAVE_CAN_INTTYPES=1 -DHAVE_SIG_T=1 -DHAVE_STRERRORDESC_NP=0 -DHAVE_SYS_ERRLIST=1 -DHAVE_SIGABBREV_NP=0 -DHAVE_SYS_SIGNAME=0 -DHAVE_SIGDESCR_NP=0 -DHAVE_SYS_SIGLIST=1 -DHAVE_FLOCK=1 -DHAVE_LOCK_FCNTL=1 -DHAVE_RLIMIT=1 -DHAVE_GET_CURRENT_DIR_NAME=1 -DHAVE_GETRANDOM=0 -DHAVE_GETRUSAGE=1 -DHAVE_GETSID=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_KILLPG=1 -DHAVE_MEMMOVE=1 -DHAVE_MKNOD=0 -DHAVE_MMAP=1 -DHAVE_FTRUNCATE=1 -DHAVE_NICE=0 -DHAVE_RENAME=1 -DHAVE_REVOKE=0 -DHAVE_POSIX_UTF8_LOCALE=0 -DHAVE_SELECT=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_SIGACTION=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 -DHAVE_STRLCPY=1 -DHAVE_STRSTR=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 -Dst_mtimensec=st_mtime_nsec -DHAVE_ST_MTIMENSEC=1 -DHAVE_INTCONSTEXPR_RSIZE_MAX=0 -DHAVE_PERSISTENT_HISTORY=0 -DMKSH_BUILD_R=599 -c ../../main.c || exit 1
] diet -v -Os gcc -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fstack-protector-strong -fwrapv  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed   -fno-lto -o $tcfn lalloc.o edit.o eval.o exec.o expr.o funcs.o histrap.o jobs.o lex.o main.o misc.o shf.o syn.o tree.o var.o ulimit.o  || for _f in ${tcfn}*; do case $_f in lksh.1|mksh.1|mksh.faq|mksh.ico) ;; *) rm -f "$_f" ;; esac; done
Resulting binary:
|    text	   data	    bss	    dec	    hex	filename
|  235288	   5496	   6060	 246844	  3c43c	builddir/static-dietlibc/mksh
----
Build information for static-klibc mksh
set -A check_categories --  shell:legacy-no int:32 shell:textmode-no shell:binmode-yes smksh binsh no-histfile stdout-ed no-stderr-ed have:select:1
Result: regressed (broken<failed<firstbuilt<checked<unattended<regressed)
Variables used:
| CC='klcc'
| CFLAGS='-g -Os -march=armv8-a -mtune=generic -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra'
| CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED -DMKSH_SMALL -DMKSH_SMALL_BUT_FAST'
| LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed'
| LDSTATIC='-static'
| LIBS=''
Actual compilation options:
] klcc -g -Os -march=armv8-a -mtune=generic -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fwrapv  -I. -I'../..' -Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED -DMKSH_SMALL -DMKSH_SMALL_BUT_FAST -DMKSH_BUILDSH=1 -D_GNU_SOURCE -DSETUID_CAN_FAIL_WITH_EAGAIN=1 -DMKSH_NO_SIGSETJMP=1 -D_setjmp=setjmp -D_longjmp=longjmp -DHAVE_STRING_POOLING=2 -DHAVE_ATTRIBUTE_BOUNDED=0 -DHAVE_ATTRIBUTE_FORMAT=1 -DHAVE_ATTRIBUTE_NORETURN=1 -DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_TIME_H=1 -DHAVE_TIME_H=1 -DHAVE_BOTH_TIME_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SELECT_TIME_H=1 -DHAVE_SYS_BSDTYPES_H=0 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_PTEM_H=0 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_SYS_SYSMACROS_H=1 -DHAVE_BSTRING_H=0 -DHAVE_GRP_H=1 -DHAVE_IO_H=0 -DHAVE_LIBGEN_H=0 -DHAVE_LIBUTIL_H=0 -DHAVE_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=0 -DHAVE_TERMIOS_H=1 -DHAVE_ULIMIT_H=0 -DHAVE_CAN_INTTYPES=1 -Dsig_t=__sighandler_t -DHAVE_SIG_T=1 -DHAVE_STRERRORDESC_NP=0 -DHAVE_SYS_ERRLIST=1 -DHAVE_SIGABBREV_NP=0 -DHAVE_SYS_SIGNAME=0 -DHAVE_SIGDESCR_NP=0 -DHAVE_SYS_SIGLIST=1 -DHAVE_FLOCK=1 -DHAVE_LOCK_FCNTL=1 -DHAVE_RLIMIT=0 -DHAVE_GET_CURRENT_DIR_NAME=0 -DHAVE_GETRANDOM=0 -DHAVE_GETRUSAGE=1 -DHAVE_GETSID=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_KILLPG=0 -DHAVE_MEMMOVE=1 -DHAVE_MKNOD=0 -DHAVE_MMAP=1 -DHAVE_FTRUNCATE=1 -DHAVE_NICE=0 -DHAVE_RENAME=1 -DHAVE_REVOKE=0 -DHAVE_POSIX_UTF8_LOCALE=0 -DHAVE_SELECT=1 -DHAVE_SETRESUGID=0 -DHAVE_SETGROUPS=0 -DHAVE_SIGACTION=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 -DHAVE_STRLCPY=1 -DHAVE_STRSTR=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_ERRLIST_DECL=0 -DHAVE_SYS_SIGLIST_DECL=1 -Dst_mtimensec=st_mtim.tv_nsec -DHAVE_ST_MTIMENSEC=1 -DHAVE_INTCONSTEXPR_RSIZE_MAX=0 -DHAVE_PERSISTENT_HISTORY=0 -DMKSH_UNLIMITED=1 -DMKSH_BUILD_R=599 -c ../../main.c || exit 1
] klcc -g -Os -march=armv8-a -mtune=generic -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fwrapv  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -static -fno-lto -o $tcfn lalloc.o edit.o eval.o exec.o expr.o funcs.o histrap.o jobs.o lex.o main.o misc.o shf.o syn.o tree.o var.o  || for _f in ${tcfn}*; do case $_f in lksh.1|mksh.1|mksh.faq|mksh.ico) ;; *) rm -f "$_f" ;; esac; done
Resulting binary:
|    text	   data	    bss	    dec	    hex	filename
|  226456	    752	   7120	 234328	  39358	builddir/static-klibc/mksh
----
Build information for static-musl mksh
set -A check_categories --  shell:legacy-no int:32 shell:textmode-no shell:binmode-yes smksh binsh no-histfile stdout-ed no-stderr-ed have:select:1
gcc (Ubuntu 14.2.0-19ubuntu2) 14.2.0
Result: regressed (broken<failed<firstbuilt<checked<unattended<regressed)
Variables used:
| CC='musl-gcc'
| CFLAGS='-Os -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fPIE'
| CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED -DMKSH_SMALL -DMKSH_SMALL_BUT_FAST'
| LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed'
| LDSTATIC='-static -static-pie -Wl,-z,text'
| LIBS=''
Actual compilation options:
] musl-gcc -Os -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fPIE -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fstack-protector-strong -fwrapv  -I. -I'../..' -Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED -DMKSH_SMALL -DMKSH_SMALL_BUT_FAST -DMKSH_BUILDSH=1 -D_GNU_SOURCE -DSETUID_CAN_FAIL_WITH_EAGAIN=1 -DHAVE_STRING_POOLING=2 -DHAVE_ATTRIBUTE_BOUNDED=0 -DHAVE_ATTRIBUTE_FORMAT=1 -DHAVE_ATTRIBUTE_NORETURN=1 -DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_TIME_H=1 -DHAVE_TIME_H=1 -DHAVE_BOTH_TIME_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SELECT_TIME_H=1 -DHAVE_SYS_BSDTYPES_H=0 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_PTEM_H=0 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_SYS_SYSMACROS_H=1 -DHAVE_BSTRING_H=0 -DHAVE_GRP_H=1 -DHAVE_IO_H=0 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 -DHAVE_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_ULIMIT_H=1 -DHAVE_CAN_INTTYPES=1 -DHAVE_SIG_T=1 -DHAVE_STRERRORDESC_NP=0 -DHAVE_SYS_ERRLIST=0 -DHAVE_SIGABBREV_NP=0 -DHAVE_SYS_SIGNAME=0 -DHAVE_SIGDESCR_NP=0 -DHAVE_SYS_SIGLIST=0 -DHAVE_FLOCK=1 -DHAVE_LOCK_FCNTL=1 -DHAVE_RLIMIT=1 -DHAVE_GET_CURRENT_DIR_NAME=1 -DHAVE_GETRANDOM=1 -DHAVE_GETRUSAGE=1 -DHAVE_GETSID=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_KILLPG=1 -DHAVE_MEMMOVE=1 -DHAVE_MKNOD=0 -DHAVE_MMAP=1 -DHAVE_FTRUNCATE=1 -DHAVE_NICE=0 -DHAVE_RENAME=1 -DHAVE_REVOKE=0 -DHAVE_POSIX_UTF8_LOCALE=1 -DHAVE_SELECT=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_SIGACTION=1 -DHAVE_STRERROR=1 -DHAVE_STRSIGNAL=1 -DHAVE_STRLCPY=1 -DHAVE_STRSTR=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_ERRLIST_DECL=0 -DHAVE_SYS_SIGLIST_DECL=0 -Dst_mtimensec=st_mtim.tv_nsec -DHAVE_ST_MTIMENSEC=1 -DHAVE_INTCONSTEXPR_RSIZE_MAX=0 -DHAVE_PERSISTENT_HISTORY=0 -DMKSH_BUILD_R=599 -c ../../main.c || exit 1
] musl-gcc -Os -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fPIE -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fstack-protector-strong -fwrapv  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -static -static-pie -Wl,-z,text -fno-lto -o $tcfn lalloc.o edit.o eval.o exec.o expr.o funcs.o histrap.o jobs.o lex.o main.o misc.o shf.o syn.o tree.o var.o ulimit.o  || for _f in ${tcfn}*; do case $_f in lksh.1|mksh.1|mksh.faq|mksh.ico) ;; *) rm -f "$_f" ;; esac; done
Resulting binary:
|    text	   data	    bss	    dec	    hex	filename
|  278269	   6040	   9208	 293517	  47a8d	builddir/static-musl/mksh
----
Build information for legacy mksh
set -A check_categories --  shell:legacy-yes shell:textmode-no shell:binmode-yes binsh no-histfile int:64 stdout-ed no-stderr-ed have:select:1 printf-builtin
gcc (Ubuntu 14.2.0-19ubuntu2) 14.2.0
Result: regressed (broken<failed<firstbuilt<checked<unattended<regressed)
Variables used:
| CC='musl-gcc'
| CFLAGS='-O2 -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fPIE'
| CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED'
| LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed'
| LDSTATIC='-static -static-pie -Wl,-z,text'
| LIBS=''
Actual compilation options:
] musl-gcc -O2 -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fPIE -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fstack-protector-strong -fwrapv  -I. -I'../..' -Wdate-time -D_FORTIFY_SOURCE=3 -DMKSH_EARLY_LOCALE_TRACKING -DKSH_VERSIONNAME_VENDOR_EXT=\"\ +Debian\" -DMKSH_BUILDMEAT -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED -DMKSH_BUILDSH=1 -DMKSH_LEGACY_MODE=1 -D_GNU_SOURCE -DSETUID_CAN_FAIL_WITH_EAGAIN=1 -DHAVE_STRING_POOLING=2 -DHAVE_ATTRIBUTE_BOUNDED=0 -DHAVE_ATTRIBUTE_FORMAT=1 -DHAVE_ATTRIBUTE_NORETURN=1 -DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_TIME_H=1 -DHAVE_TIME_H=1 -DHAVE_BOTH_TIME_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SELECT_TIME_H=1 -DHAVE_SYS_BSDTYPES_H=0 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_PTEM_H=0 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_SYS_SYSMACROS_H=1 -DHAVE_BSTRING_H=0 -DHAVE_GRP_H=1 -DHAVE_IO_H=0 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 -DHAVE_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_TERMIOS_H=1 -DHAVE_ULIMIT_H=1 -DHAVE_CAN_INTTYPES=1 -DHAVE_SIG_T=1 -DHAVE_STRERRORDESC_NP=0 -DHAVE_SYS_ERRLIST=0 -DHAVE_SIGABBREV_NP=0 -DHAVE_SYS_SIGNAME=0 -DHAVE_SIGDESCR_NP=0 -DHAVE_SYS_SIGLIST=0 -DHAVE_FLOCK=1 -DHAVE_LOCK_FCNTL=1 -DHAVE_RLIMIT=1 -DHAVE_GET_CURRENT_DIR_NAME=1 -DHAVE_GETRANDOM=1 -DHAVE_GETRUSAGE=1 -DHAVE_GETSID=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_KILLPG=1 -DHAVE_MEMMOVE=1 -DHAVE_MKNOD=0 -DHAVE_MMAP=1 -DHAVE_FTRUNCATE=1 -DHAVE_NICE=1 -DHAVE_RENAME=1 -DHAVE_REVOKE=0 -DHAVE_POSIX_UTF8_LOCALE=1 -DHAVE_SELECT=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_SIGACTION=1 -DHAVE_STRERROR=1 -DHAVE_STRSIGNAL=1 -DHAVE_STRLCPY=1 -DHAVE_STRSTR=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_ERRLIST_DECL=0 -DHAVE_SYS_SIGLIST_DECL=0 -Dst_mtimensec=st_mtim.tv_nsec -DHAVE_ST_MTIMENSEC=1 -DHAVE_INTCONSTEXPR_RSIZE_MAX=0 -DHAVE_PERSISTENT_HISTORY=0 -DHAVE_LONG_32BIT=0 -DHAVE_LONG_64BIT=1 -DMKSH_PRINTF_BUILTIN=1 -DMKSH_BUILD_R=599 -c ../../main.c || exit 1
] musl-gcc -O2 -g -Werror=implicit-function-declaration -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/«builddir»=. -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/«builddir»=/usr/src/mksh-59c-41 -Wall -Wextra -fPIE -fno-lto -Wno-deprecated-declarations -fno-asynchronous-unwind-tables -fno-strict-aliasing -fstack-protector-strong -fwrapv  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -static -static-pie -Wl,-z,text -fno-lto -o $tcfn lalloc.o edit.o eval.o exec.o expr.o funcs.o histrap.o jobs.o lex.o main.o misc.o shf.o syn.o tree.o var.o printf.o ulimit.o  || for _f in ${tcfn}*; do case $_f in lksh.1|mksh.1|mksh.faq|mksh.ico) ;; *) rm -f "$_f" ;; esac; done
Resulting binary:
|    text	   data	    bss	    dec	    hex	filename
|  375105	   6600	   9824	 391529	  5f969	builddir/legacy/lksh
----
Version: 59c-41
