From: Arkadiusz Miƛkiewicz Date: Tue, 22 Nov 2011 21:22:14 +0000 (+0000) Subject: Applied fixes/suggestions from mksh maintainer: X-Git-Tag: auto/th/mksh-40c-1~1 X-Git-Url: http://git.pld-linux.org/gitweb.cgi?p=packages%2Fmksh.git;a=commitdiff_plain;h=09685ada1aa7ee892a85badcd368e42d54dbcc38 Applied fixes/suggestions from mksh maintainer: 21:36 replace `id -u` with $USER_ID 21:36 it's set by mksh 21:36 and PLEASE do not use ` 21:36 especially as one cannot reliably use quotes inside it 21:37 line 30-39 are also obsolete (in fact, dangerous) (refering to keyboard binding) 22:11 you could use [[ (and (( for the USER_ID comparison) 22:11 that would save some "" 22:11 the echo argument could use some "" though 22:12 and it was agreed among shell developers that default configs SHOULD NOT export PS1 Changed files: mksh-mkshrc -> 1.3 --- diff --git a/mksh-mkshrc b/mksh-mkshrc index e15906d..1efd688 100644 --- a/mksh-mkshrc +++ b/mksh-mkshrc @@ -1,51 +1,32 @@ # For interactive shell # PROMPT -if [ `id -u` -eq 0 ]; then - PS1='[${LOGNAME-$USER}@${HOSTNAME} ` - if [ "$PWD" = "$HOME" ]; then - echo "~"; - elif [ "$PWD" = "/${PWD##*/}" ]; then - echo $PWD; - else - echo ${PWD##*/}; - fi`]# ' +PS1='[${LOGNAME-$USER}@${HOSTNAME} $( +if [[ $PWD = "$HOME" ]]; then + echo "~" +elif [[ $PWD = "/${PWD##*/}" ]]; then + print -r -- "$PWD" else - PS1='[${LOGNAME-$USER}@${HOSTNAME} ` - if [ "$PWD" = "$HOME" ]; then - echo "~"; - elif [ "$PWD" = "/${PWD##*/}" ]; then - echo $PWD; - else - echo ${PWD##*/}; - fi`]$ ' + print -r -- "${PWD##*/}" +fi)]' +if (( USER_ID == 0 )); then + PS1+='# ' +else + PS1+='$ ' fi -export PS1 # EDITING FUNCTIONS set -o emacs -bind '^I'=complete >/dev/null 2>&1 bind '^I'=complete-list >/dev/null 2>&1 -case $TERM in - nxterm|xterm*|konsole*) - bind '^[[H'=beginning-of-line >/dev/null 2>&1 - bind '^[[F'=end-of-line >/dev/null 2>&1 - ;; - linux|rxvt*) - bind '^[[1~'=beginning-of-line >/dev/null 2>&1 - bind '^[[4~'=end-of-line >/dev/null 2>&1 - ;; -esac - # SYSTEM WIDE ALIASES ETC. -if [ "`echo /etc/shrc.d/*.sh`" != "/etc/shrc.d/*.sh" ]; then - for i in /etc/shrc.d/*.sh ; do - . $i - done - unset i -fi +for i in /etc/shrc.d/*.sh; do + [[ -e $i ]] || continue + . "$i" +done +unset i HISTFILE=~/.history.mksh # vi:syntax=sh +