Update mksh to R43 (formal release, from tarball)
The files in src/ are just the unmodified mksh release .tgz
and is Not a Contribution to Android, it’s the upstream code
project. ChangeLog: https://www.mirbsd.org/mksh.htm#clog
Changes, other than upstream mksh code:
• update Copyright years
• sync with moving to a different AOSP project and other AOSP changes
• mkmf.sh: add test compilation mode
• be conservative in filedescriptor usage
• don’t compile the $MirOS$ RCS IDs into the binary to save space
• enable UTF-8 mode, to match reality
• help memory leak debugging by adding -DDEBUG_LEAKS
• update rest of mkmf.sh to work with updated AOSP and mksh
• use ro.product.device property as default hostname in mkshrc
(originally submitted by John Michelau <john.michelau@motorola.com>)
• do not export PS1 in mkshrc (cross-shell developers agreed on this)
• add “more” function to mkshrc to get a simplistic pager
• add “hd” and “setenv” functions to mkshrc for better UX
• mention Launchpad as upstream bugtracker as comment in mkshrc
• change TMPDIR to /data/local/tmp for now, as /sqlite_stmt_journals is gone
(although this is still no full replacement, it’s better than before)
• address the segfaults seen by DONG-DONG YANG
Change-Id: I2d4d175bc5163b3d6f5098024f98f316fe812e55
diff --git a/mkshrc b/mkshrc
index 0da5ea6..2951595 100644
--- a/mkshrc
+++ b/mkshrc
@@ -1,11 +1,13 @@
-# Copyright (c) 2010
-# Thorsten Glaser <t.glaser@tarent.de>
+# Copyright (c) 2010, 2012, 2013
+# Thorsten Glaser <tg@mirbsd.org>
# This file is provided under the same terms as mksh.
#-
# Minimal /system/etc/mkshrc for Android
+#
+# Support: https://launchpad.net/mksh
-: ${TERM:=vt100} ${HOME:=/data} ${MKSH:=/system/bin/sh} ${HOSTNAME:=android}
-: ${SHELL:=$MKSH} ${USER:=$(typeset x=$(id); x=${x#*\(}; print -r -- ${x%%\)*})}
+: ${TERM:=vt100} ${HOME:=/data} ${MKSH:=/system/bin/sh} ${HOSTNAME:=$(getprop ro.product.device)}
+: ${SHELL:=$MKSH} ${USER:=$(typeset x=$(id); x=${x#*\(}; print -r -- ${x%%\)*})} ${HOSTNAME:=android}
if (( USER_ID )); then PS1='$'; else PS1='#'; fi
function precmd {
typeset e=$?
@@ -13,12 +15,37 @@
(( e )) && print -n "$e|"
}
PS1='$(precmd)$USER@$HOSTNAME:${PWD:-?} '"$PS1 "
-export HOME HOSTNAME MKSH PS1 SHELL TERM USER
+export HOME HOSTNAME MKSH SHELL TERM USER
alias l='ls'
alias la='l -a'
alias ll='l -l'
alias lo='l -a -l'
+function hd {
+ cat "$@" | command hd /proc/self/fd/0
+}
+
+function more {
+ local dummy line llen curlin=0
+
+ cat "$@" | while IFS= read -r line; do
+ llen=${%line}
+ (( llen == -1 )) && llen=${#line}
+ (( llen = llen ? (llen + COLUMNS - 1) / COLUMNS : 1 ))
+ if (( (curlin += llen) >= LINES )); then
+ print -n -- '\033[7m--more--\033[0m'
+ read -u1 dummy
+ [[ $dummy = [Qq]* ]] && return 0
+ curlin=$llen
+ fi
+ print -r -- "$line"
+ done
+}
+
+function setenv {
+ eval export "\"$1\""'="$2"'
+}
+
for p in ~/.bin; do
[[ -d $p/. ]] || continue
[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH