• from a MirOS point of view:

place most stuff from /etc/profile in /etc/skel/.mkshrc; admins must make
  sure to copy this file to users' homes on upgrade (benefit: non-login but
  interactive shells also get all the goodies); fix some quoting; simplify,
  reformat, change comments
• from an mksh point of view:
  slight internal changes in dot.mkshrc; external commands are now prefixed
  with “ulimit -c 0”; $TERM is defined; improvement in determining the host
  name (e.g. on Debian if a FQDN is not given); declare locals as such both
  in $PS1 and outside; remove superfluous quoting, quote properly; simplify
  hd alias, add rot13 alias; place RCS ID at the bottom
This commit is contained in:
tg 2007-04-16 18:54:37 +00:00
parent 680e8ebd3f
commit c79cacdfa5
2 changed files with 25 additions and 17 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/Makefile,v 1.35 2007/03/04 04:36:45 tg Exp $
# $MirOS: src/bin/mksh/Makefile,v 1.36 2007/04/16 18:54:37 tg Exp $
#-
# use CPPFLAGS=-DDEBUG __CRAZY=Yes to check for certain more stuff
@ -48,4 +48,8 @@ cleandir: clean-extra
clean-extra: .PHONY
-rm -rf build-dir regress-dir
distribution:
${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${CONFGRP} -m 0644 \
${.CURDIR}/dot.mkshrc ${DESTDIR}/etc/skel/.mkshrc
.include <bsd.prog.mk>

View File

@ -1,30 +1,34 @@
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.8 2007/03/04 06:20:48 tg Exp $
: ${EDITOR:=/bin/ed} ${HOSTNAME:=$(hostname -s 2>/dev/null || hostname)}
PS1='$(((rv=$?)) && print $rv\|)${USER:=$(id -un)}@${HOSTNAME:=nil}:$(
local pfx=~ wd=${PWD:-$(pwd)}
: ${EDITOR:=/bin/ed} ${TERM:=vt100}
[[ ${HOSTNAME:=$(ulimit -c 0; hostname -s 2>/dev/null)} = \
@(localhost|*([ ])) ]] && HOSTNAME=$(ulimit -c 0; hostname 2>/dev/null)
if [[ $(ulimit -c 0; id -u 2>/dev/null) -eq 0 ]]; then
PS1='# '
else
PS1='$ '
fi; PS1='$(integer rv=$?; ((rv)) && print -n $rv\|)${USER:=$(ulimit -c 0; \
id -un 2>/dev/null || print -n nobody)}@${HOSTNAME:=nil}:$(
local pfx=~ wd=${PWD:-$(builtin pwd)}; integer n=${COLUMNS:-80}/3
[[ ${wd#$pfx} = $wd || $pfx = ?(/) ]] || wd=\~${wd#$pfx}
pfx=; let n="( (n = ${COLUMNS:-80} / 3) < 7 ? 7 : n)"
pfx=; let n="n < 7 ? 7 : n"
while (( (${#pfx} + ${#wd}) > n )); do
if [[ $wd = */* ]]; then
pfx=.../
wd="${wd#*/}"
wd=${wd#*/}
else
pfx=...
wd="${wd#?????}"
wd=${wd#?????}
fi
done
print -r -- "$pfx$wd")'" $(if (( $(id -u) )); then
print \$; else print \#; fi) "
export EDITOR HOSTNAME MKSH=$(whence -p mksh) PS1 USER
print -nr -- "$pfx$wd") '$PS1
export EDITOR HOSTNAME MKSH="$(whence -p mksh)" PS1 TERM USER
alias l='/bin/ls -F'
alias la='l -a'
alias ll='l -l'
alias lo='la -lo'
[ -x /usr/bin/hd ] || eval alias hd="'hexdump -e '\\''\"%08.8_ax \" 8/1" \
'"%02X " " - " 8/1 "%02X "'"'\\'' -e '\\''"'" |" "%_p"'"'\\''" \
"-e '\\''"'"|\n"'"'\\'' '"
whence -p rot13 >/dev/null || alias rot13='tr [A-Za-z] [N-ZA-Mn-za-m]'
whence -p hd >/dev/null || alias hd="hexdump -e '"'"%08.8_ax " 8/1 '\
'"%02X " " - " 8/1 "%02X "'"' -e '\" |\" \"%_p\"' -e '\"|\\n\"'"
# strip comments (and leading/trailing whitespace if IFS is set) from
# any file(s) given as argument, or stdin if none, and spew to stdout
@ -36,6 +40,6 @@ function Lstripcom
done; }
}
# Your shell code goes below!
# place customisations between this line and the ": RCSID" line below
: Your shell code goes above!
: $MirOS: src/bin/mksh/dot.mkshrc,v 1.9 2007/04/16 18:54:37 tg Exp $