2007-03-04 07:20:48 +01:00
|
|
|
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.8 2007/03/04 06:20:48 tg Exp $
|
2006-07-23 20:44:22 +02:00
|
|
|
|
2006-08-28 03:34:47 +02:00
|
|
|
: ${EDITOR:=/bin/ed} ${HOSTNAME:=$(hostname -s 2>/dev/null || hostname)}
|
2006-07-23 20:44:22 +02:00
|
|
|
PS1='$(((rv=$?)) && print $rv\|)${USER:=$(id -un)}@${HOSTNAME:=nil}:$(
|
|
|
|
local pfx=~ wd=${PWD:-$(pwd)}
|
|
|
|
[[ ${wd#$pfx} = $wd || $pfx = ?(/) ]] || wd=\~${wd#$pfx}
|
|
|
|
pfx=; let n="( (n = ${COLUMNS:-80} / 3) < 7 ? 7 : n)"
|
|
|
|
while (( (${#pfx} + ${#wd}) > n )); do
|
|
|
|
if [[ $wd = */* ]]; then
|
|
|
|
pfx=.../
|
|
|
|
wd="${wd#*/}"
|
|
|
|
else
|
|
|
|
pfx=...
|
|
|
|
wd="${wd#?????}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
print -r -- "$pfx$wd")'" $(if (( $(id -u) )); then
|
• remove strcasestr.c, use home-grown implementation¹, call it stricmp,
and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version
¹) side effect from creating API-correct cstrchr, cstrstr, etc.
uses goto so it must be better ☻
tested on mirbsd-current via both Makefile and Build.sh
2007-03-04 04:04:28 +01:00
|
|
|
print \$; else print \#; fi) "
|
|
|
|
export EDITOR HOSTNAME MKSH=$(whence -p mksh) PS1 USER
|
2006-07-23 20:44:22 +02:00
|
|
|
|
|
|
|
alias l='/bin/ls -F'
|
|
|
|
alias la='l -a'
|
|
|
|
alias ll='l -l'
|
|
|
|
alias lo='la -lo'
|
2007-02-17 07:34:46 +01:00
|
|
|
[ -x /usr/bin/hd ] || eval alias hd="'hexdump -e '\\''\"%08.8_ax \" 8/1" \
|
|
|
|
'"%02X " " - " 8/1 "%02X "'"'\\'' -e '\\''"'" |" "%_p"'"'\\''" \
|
|
|
|
"-e '\\''"'"|\n"'"'\\'' '"
|
2006-07-23 20:44:22 +02:00
|
|
|
|
2006-08-14 22:32:44 +02:00
|
|
|
# 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
|
|
|
|
function Lstripcom
|
2006-07-23 20:44:22 +02:00
|
|
|
{
|
• remove strcasestr.c, use home-grown implementation¹, call it stricmp,
and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version
¹) side effect from creating API-correct cstrchr, cstrstr, etc.
uses goto so it must be better ☻
tested on mirbsd-current via both Makefile and Build.sh
2007-03-04 04:04:28 +01:00
|
|
|
cat "$@" | { set -o noglob; while read _line; do
|
2006-07-23 20:44:22 +02:00
|
|
|
_line=${_line%%#*}
|
|
|
|
[[ -n $_line ]] && print -r -- $_line
|
• remove strcasestr.c, use home-grown implementation¹, call it stricmp,
and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version
¹) side effect from creating API-correct cstrchr, cstrstr, etc.
uses goto so it must be better ☻
tested on mirbsd-current via both Makefile and Build.sh
2007-03-04 04:04:28 +01:00
|
|
|
done; }
|
2006-07-23 20:44:22 +02:00
|
|
|
}
|
2007-03-04 07:20:48 +01:00
|
|
|
|
|
|
|
# Your shell code goes below!
|
|
|
|
|
|
|
|
: Your shell code goes above!
|