From 451aef7a8ae08574f0d8f3c20ca10ec8786a3bfb Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 11 Apr 2015 18:08:56 +0000 Subject: [PATCH] =?UTF-8?q?some=20robustness=20improvements=20for=20dot.mk?= =?UTF-8?q?shrc:=20=E2=80=A2=20do=20not=20use=20\return=20for=20return=20b?= =?UTF-8?q?efore=20we=20know=20we=20are=20mksh=20=20=20(plus=20fix=20a=20w?= =?UTF-8?q?rong-word=20mistake)=20=E2=80=A2=20quote=20the=20argument(s)=20?= =?UTF-8?q?to=20\:=20(=E2=80=9Ccolon=E2=80=9D)=20for=20SECURITY=20?= =?UTF-8?q?=E2=80=A2=20default=20$MKSH=20to=20/bin/mksh=20(not=20normally?= =?UTF-8?q?=20reached)=20=E2=80=A2=20while=20here:=20check=20$USER=20only?= =?UTF-8?q?=20once,=20not=20for=20each=20PS1=20(speed)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this addresses and mostly closes LP#1441853 – prt.mkshrc (in OBS home:mirabile/mksh and DEB wtf-mksh they are identical) is already good; Android mkshrc needs only some small robustness fixes (mostly colon-related; enh says TMPDIR is good); I tested this with “mksh -eu” and “mksh -eul” on Debian and ecce and with read-only “/” and nothing else mounted on ecce, and it WFM --- dot.mkshrc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dot.mkshrc b/dot.mkshrc index d0c245e..bfef1fe 100644 --- a/dot.mkshrc +++ b/dot.mkshrc @@ -1,5 +1,5 @@ # $Id$ -# $MirOS: src/bin/mksh/dot.mkshrc,v 1.94 2015/03/14 05:23:14 tg Exp $ +# $MirOS: src/bin/mksh/dot.mkshrc,v 1.95 2015/04/11 18:08:56 tg Exp $ #- # Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013, 2014, 2015 @@ -22,21 +22,22 @@ #- # ${ENV:-~/.mkshrc}: mksh initialisation file for interactive shells -# catch non-mksh (including lksh) trying to shell this file +# catch non-mksh (including lksh) trying to run this file case $KSH_VERSION in *MIRBSD\ KSH*) ;; -*) \return 0 ;; +*) return 0 ;; esac PS1='#'; (( USER_ID )) && PS1='$'; [[ ${HOSTNAME:=$(\ulimit -c 0; hostname -s \ 2>/dev/null)} = *([ ]|localhost) ]] && HOSTNAME=$(\ulimit -c 0; hostname \ - 2>/dev/null); \: ${EDITOR:=/bin/ed} ${HOSTNAME:=nil} ${TERM:=vt100} -\: ${MKSH:=$(\builtin whence -p mksh)}; PS4='[$EPOCHREALTIME] '; PS1=$'\001\r''${| + 2>/dev/null); \: "${EDITOR:=/bin/ed} ${HOSTNAME:=nil} ${MKSH:=$(\builtin \ + whence -p mksh || \echo /bin/mksh)} ${TERM:=vt100} ${USER:=$(\ulimit -c 0; \ + id -un 2>/dev/null || \echo \?)}" +PS4='[$EPOCHREALTIME] '; PS1=$'\001\r''${| \typeset e=$? (( e )) && REPLY+="$e|" - REPLY+=${USER:=$(\ulimit -c 0; id -un 2>/dev/null || \echo \?)} - REPLY+=@${HOSTNAME%%.*}: + REPLY+=${USER}@${HOSTNAME%%.*}: \typeset d=${PWD:-?} p=~; [[ $p = ?(*/) ]] || d=${d/#$p/~} \typeset m=${%d} n p=...; (( m > 0 )) || m=${#d}