• be friendlier to AT&T ksh: use only signed (standard) integers

‣ now, a “ksh93” just requires ‘function precmd { :; }; set -o emacs’
    afterwards to get rid of the annoying error messages
  ‣ I could lose that with the following idiom:
    - PS1='$(precmd)…
    + PS1='$(typeset -i e=$?; typeset -f precmd >&- && { (return $e); precmd })…
    but it didn’t seem worthwhile to me
• remove explicit licence blah, normal ./copyright applies
This commit is contained in:
tg 2008-04-22 13:48:15 +00:00
parent 487da1357e
commit e57f5fc09b
1 changed files with 4 additions and 27 deletions

View File

@ -1,41 +1,18 @@
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.32 2008/04/19 22:03:19 tg Stab $
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.33 2008/04/22 13:48:15 tg Rel $
#-
# Copyright (c) 2007, 2008
# Thorsten “mirabilos” Glaser <tg@mirbsd.de>
#
# 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.
#
# Advertising materials mentioning features or use of this work must
# display the following acknowledgement:
# This product includes material provided by Thorsten Glaser.
#
# 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.
#-
# sample mksh initialisation file for interactive shells; install as
# /etc/skel/.mkshrc (as root, for new accounts) or copy to ~/.mkshrc
# ~/.mkshrc: mksh initialisation file for interactive shells
: ${EDITOR:=/bin/ed} ${TERM:=vt100} ${HOSTNAME:=$(ulimit -c 0;hostname -s 2>&-)}
[[ $HOSTNAME = @(localhost|*([ ])) ]] && HOSTNAME=$(ulimit -c 0;hostname 2>&-)
: ${HOSTNAME:=nil}; PS1='#'; [[ "$(ulimit -c 0; id -u 2>&-)" -eq 0 ]] || PS1='$'
function precmd {
typeset -Ui10 e=$?
typeset -i e=$?
(( e )) && print -n "$e|"
}
PS1='$(precmd)${USER:=$(ulimit -c 0;id -un 2>&- || print \?)}@${HOSTNAME%%.*}:$(
typeset pfx=~ wd=${PWD:-?}
typeset -Ui n=${COLUMNS:-80}/3; (( n = n < 7 ? 7 : n ))
typeset -i n=${COLUMNS:-80}/3; (( n = n < 7 ? 7 : n ))
wd=${wd/#$pfx/~}
pfx=; while (( (${#pfx} + ${#wd}) > n )); do
if [[ $wd = */* ]]; then