• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# $Id$
2# $MirOS: src/bin/mksh/dot.mkshrc,v 1.121 2017/08/08 21:10:21 tg Exp $
3#-
4# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
5#		2011, 2012, 2013, 2014, 2015, 2016, 2017
6#	mirabilos <m@mirbsd.org>
7#
8# Provided that these terms and disclaimer and all copyright notices
9# are retained or reproduced in an accompanying document, permission
10# is granted to deal in this work without restriction, including un-
11# limited rights to use, publicly perform, distribute, sell, modify,
12# merge, give away, or sublicence.
13#
14# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
15# the utmost extent permitted by applicable law, neither express nor
16# implied; without malicious intent or gross negligence. In no event
17# may a licensor, author or contributor be held liable for indirect,
18# direct, other damage, loss, or other issues arising in any way out
19# of dealing in the work, even if advised of the possibility of such
20# damage or existence of a defect, except proven that it results out
21# of said person's immediate fault when using the work as intended.
22#-
23# ${ENV:-~/.mkshrc}: mksh initialisation file for interactive shells
24
25# catch non-mksh, non-lksh, trying to run this file
26case ${KSH_VERSION:-} in
27*LEGACY\ KSH*|*MIRBSD\ KSH*) ;;
28*) \return 0 ;;
29esac
30
31# give MidnightBSD's laffer1 a bit of csh feeling
32function setenv {
33	if (( $# )); then
34		\\builtin eval '\\builtin export "$1"="${2:-}"'
35	else
36		\\builtin typeset -x
37	fi
38}
39
40# pager (not control character safe)
41smores() (
42	\\builtin set +m
43	\\builtin cat "$@" |&
44	\\builtin trap "rv=\$?; \\\\builtin kill $! >/dev/null 2>&1; \\\\builtin exit \$rv" EXIT
45	while IFS= \\builtin read -pr line; do
46		llen=${%line}
47		(( llen == -1 )) && llen=${#line}
48		(( llen = llen ? (llen + COLUMNS - 1) / COLUMNS : 1 ))
49		if (( (curlin += llen) >= LINES )); then
50			\\builtin print -nr -- $'\e[7m--more--\e[0m'
51			\\builtin read -u1 || \\builtin exit $?
52			[[ $REPLY = [Qq]* ]] && \\builtin exit 0
53			curlin=$llen
54		fi
55		\\builtin print -r -- "$line"
56	done
57)
58
59# customise your favourite editor here; the first one found is used
60for EDITOR in "${EDITOR:-}" jupp jstar mcedit ed vi; do
61	EDITOR=$(\\builtin whence -p "$EDITOR") || EDITOR=
62	[[ -n $EDITOR && -x $EDITOR ]] && break
63	EDITOR=
64done
65
66\\builtin alias ls=ls l='ls -F' la='l -a' ll='l -l' lo='l -alo'
67\: "${HOSTNAME:=$(\\builtin ulimit -c 0; \\builtin print -r -- $(hostname \
68    2>/dev/null))}${EDITOR:=/bin/ed}${TERM:=vt100}${USER:=$(\\builtin ulimit \
69    -c 0; id -un 2>/dev/null)}${USER:=?}"
70[[ $HOSTNAME = ?(?(ip6-)localhost?(6)) ]] && HOSTNAME=nil; \\builtin unalias ls
71\\builtin export EDITOR HOSTNAME TERM USER
72
73# minimal support for lksh users
74if [[ $KSH_VERSION = *LEGACY\ KSH* ]]; then
75	PS1='$USER@${HOSTNAME%%.*}:$PWD>'
76	\\builtin return 0
77fi
78
79# mksh-specific from here
80\: "${MKSH:=$(\\builtin whence -p mksh)}${MKSH:=/bin/mksh}"
81\\builtin export MKSH
82
83# prompts
84PS4='[$EPOCHREALTIME] '; PS1='#'; (( USER_ID )) && PS1='$'; PS1=$'\001\r''${|
85	\\builtin typeset e=$?
86
87	(( e )) && REPLY+="$e|"
88	REPLY+=${USER}@${HOSTNAME%%.*}:
89
90	\\builtin typeset d=${PWD:-?}/ p=~; [[ $p = ?(*/) ]] || d=${d/#$p\//\~/}
91	d=${d%/}; \\builtin typeset m=${%d} n p=...; (( m > 0 )) || m=${#d}
92	(( m > (n = (COLUMNS/3 < 7 ? 7 : COLUMNS/3)) )) && d=${d:(-n)} || p=
93	REPLY+=$p$d
94
95	\\builtin return $e
96} '"$PS1 "
97
98# utilities
99\\builtin alias doch='sudo mksh -c "$(\\builtin fc -ln -1)"'
100\\builtin command -v rot13 >/dev/null || \\builtin alias rot13='tr \
101    abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \
102    nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
103if \\builtin command -v hd >/dev/null; then
104	\:
105elif \\builtin command -v hexdump >/dev/null; then
106	function hd {
107		hexdump -e '"%08.8_ax  " 8/1 "%02X " " - " 8/1 "%02X "' \
108		    -e '"  |" "%_p"' -e '"|\n"' "$@"
109	}
110else
111	function hd {
112		\\builtin cat "$@" | hd_mksh "$@"
113	}
114fi
115
116# NUL-safe and EBCDIC-safe hexdump (from stdin)
117function hd_mksh {
118	\\builtin typeset -Uui16 -Z11 pos=0
119	\\builtin typeset -Uui16 -Z5 hv=2147483647
120	\\builtin typeset dasc dn line i
121	\\builtin set +U
122
123	while \\builtin read -arn 512 line; do
124		\\builtin typeset -i1 'line[*]'
125		i=0
126		while (( i < ${#line[*]} )); do
127			dn=
128			(( (hv = line[i++]) != 0 )) && dn=${line[i-1]#1#}
129			if (( (pos & 15) == 0 )); then
130				(( pos )) && \
131				    \\builtin print -r -- "$dasc|"
132				\\builtin print -nr "${pos#16#}  "
133				dasc=' |'
134			fi
135			\\builtin print -nr "${hv#16#} "
136			if [[ $dn = [[:print:]] ]]; then
137				dasc+=$dn
138			else
139				dasc+=.
140			fi
141			(( (pos++ & 15) == 7 )) && \
142			    \\builtin print -nr -- '- '
143		done
144	done
145	while (( pos & 15 )); do
146		\\builtin print -nr '   '
147		(( (pos++ & 15) == 7 )) && \
148		    \\builtin print -nr -- '- '
149	done
150	(( hv == 2147483647 )) || \\builtin print -r -- "$dasc|"
151}
152
153# Berkeley C shell compatible dirs, popd, and pushd functions
154# Z shell compatible chpwd() hook, used to update DIRSTACK[0]
155DIRSTACKBASE=$(\\builtin realpath ~/. 2>/dev/null || \
156    \\builtin print -nr -- "${HOME:-/}")
157\\builtin set -A DIRSTACK
158function chpwd {
159	DIRSTACK[0]=$(\\builtin realpath . 2>/dev/null || \
160	    \\builtin print -nr -- "$PWD")
161	[[ $DIRSTACKBASE = ?(*/) ]] || \
162	    DIRSTACK[0]=${DIRSTACK[0]/#$DIRSTACKBASE/\~}
163	\:
164}
165\chpwd .
166cd() {
167	\\builtin cd "$@" || \\builtin return $?
168	\chpwd "$@"
169}
170function cd_csh {
171	\\builtin typeset d t=${1/#\~/$DIRSTACKBASE}
172
173	if ! d=$(\\builtin cd "$t" 2>&1); then
174		\\builtin print -ru2 "${1}: ${d##*cd: $t: }."
175		\\builtin return 1
176	fi
177	\cd "$t"
178}
179function dirs {
180	\\builtin typeset d dwidth
181	\\builtin typeset -i fl=0 fv=0 fn=0 cpos=0
182
183	while \\builtin getopts ":lvn" d; do
184		case $d {
185		(l)	fl=1 ;;
186		(v)	fv=1 ;;
187		(n)	fn=1 ;;
188		(*)	\\builtin print -ru2 'Usage: dirs [-lvn].'
189			\\builtin return 1 ;;
190		}
191	done
192	\\builtin shift $((OPTIND - 1))
193	if (( $# > 0 )); then
194		\\builtin print -ru2 'Usage: dirs [-lvn].'
195		\\builtin return 1
196	fi
197	if (( fv )); then
198		fv=0
199		while (( fv < ${#DIRSTACK[*]} )); do
200			d=${DIRSTACK[fv]}
201			(( fl )) && d=${d/#\~/$DIRSTACKBASE}
202			\\builtin print -r -- "$fv	$d"
203			(( ++fv ))
204		done
205	else
206		fv=0
207		while (( fv < ${#DIRSTACK[*]} )); do
208			d=${DIRSTACK[fv]}
209			(( fl )) && d=${d/#\~/$DIRSTACKBASE}
210			(( dwidth = (${%d} > 0 ? ${%d} : ${#d}) ))
211			if (( fn && (cpos += dwidth + 1) >= 79 && \
212			    dwidth < 80 )); then
213				\\builtin print
214				(( cpos = dwidth + 1 ))
215			fi
216			\\builtin print -nr -- "$d "
217			(( ++fv ))
218		done
219		\\builtin print
220	fi
221	\\builtin return 0
222}
223function popd {
224	\\builtin typeset d fa
225	\\builtin typeset -i n=1
226
227	while \\builtin getopts ":0123456789lvn" d; do
228		case $d {
229		(l|v|n)	fa+=" -$d" ;;
230		(+*)	n=2
231			\\builtin break ;;
232		(*)	\\builtin print -ru2 'Usage: popd [-lvn] [+<n>].'
233			\\builtin return 1 ;;
234		}
235	done
236	\\builtin shift $((OPTIND - n))
237	n=0
238	if (( $# > 1 )); then
239		\\builtin print -ru2 popd: Too many arguments.
240		\\builtin return 1
241	elif [[ $1 = ++([0-9]) && $1 != +0 ]]; then
242		if (( (n = ${1#+}) >= ${#DIRSTACK[*]} )); then
243			\\builtin print -ru2 popd: Directory stack not that deep.
244			\\builtin return 1
245		fi
246	elif [[ -n $1 ]]; then
247		\\builtin print -ru2 popd: Bad directory.
248		\\builtin return 1
249	fi
250	if (( ${#DIRSTACK[*]} < 2 )); then
251		\\builtin print -ru2 popd: Directory stack empty.
252		\\builtin return 1
253	fi
254	\\builtin unset DIRSTACK[n]
255	\\builtin set -A DIRSTACK -- "${DIRSTACK[@]}"
256	\cd_csh "${DIRSTACK[0]}" || \\builtin return 1
257	\dirs $fa
258}
259function pushd {
260	\\builtin typeset d fa
261	\\builtin typeset -i n=1
262
263	while \\builtin getopts ":0123456789lvn" d; do
264		case $d {
265		(l|v|n)	fa+=" -$d" ;;
266		(+*)	n=2
267			\\builtin break ;;
268		(*)	\\builtin print -ru2 'Usage: pushd [-lvn] [<dir>|+<n>].'
269			\\builtin return 1 ;;
270		}
271	done
272	\\builtin shift $((OPTIND - n))
273	if (( $# == 0 )); then
274		if (( ${#DIRSTACK[*]} < 2 )); then
275			\\builtin print -ru2 pushd: No other directory.
276			\\builtin return 1
277		fi
278		d=${DIRSTACK[1]}
279		DIRSTACK[1]=${DIRSTACK[0]}
280		\cd_csh "$d" || \\builtin return 1
281	elif (( $# > 1 )); then
282		\\builtin print -ru2 pushd: Too many arguments.
283		\\builtin return 1
284	elif [[ $1 = ++([0-9]) && $1 != +0 ]]; then
285		if (( (n = ${1#+}) >= ${#DIRSTACK[*]} )); then
286			\\builtin print -ru2 pushd: Directory stack not that deep.
287			\\builtin return 1
288		fi
289		while (( n-- )); do
290			d=${DIRSTACK[0]}
291			\\builtin unset DIRSTACK[0]
292			\\builtin set -A DIRSTACK -- "${DIRSTACK[@]}" "$d"
293		done
294		\cd_csh "${DIRSTACK[0]}" || \\builtin return 1
295	else
296		\\builtin set -A DIRSTACK -- placeholder "${DIRSTACK[@]}"
297		\cd_csh "$1" || \\builtin return 1
298	fi
299	\dirs $fa
300}
301
302# base64 encoder and decoder, RFC compliant, NUL safe, not EBCDIC safe
303function Lb64decode {
304	\\builtin set +U
305	\\builtin typeset c s="$*" t
306	[[ -n $s ]] || { s=$(\\builtin cat; \\builtin print x); s=${s%x}; }
307	\\builtin typeset -i i=0 j=0 n=${#s} p=0 v x
308	\\builtin typeset -i16 o
309
310	while (( i < n )); do
311		c=${s:(i++):1}
312		case $c {
313		(=)	\\builtin break ;;
314		([A-Z])	(( v = 1#$c - 65 )) ;;
315		([a-z])	(( v = 1#$c - 71 )) ;;
316		([0-9])	(( v = 1#$c + 4 )) ;;
317		(+)	v=62 ;;
318		(/)	v=63 ;;
319		(*)	\\builtin continue ;;
320		}
321		(( x = (x << 6) | v ))
322		case $((p++)) {
323		(0)	\\builtin continue ;;
324		(1)	(( o = (x >> 4) & 255 )) ;;
325		(2)	(( o = (x >> 2) & 255 )) ;;
326		(3)	(( o = x & 255 ))
327			p=0
328			;;
329		}
330		t+=\\x${o#16#}
331		(( ++j & 4095 )) && \\builtin continue
332		\\builtin print -n $t
333		t=
334	done
335	\\builtin print -n $t
336}
337function Lb64encode {
338	\\builtin set +U
339	\\builtin typeset c s t table
340	\\builtin set -A table -- A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \
341	    a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 + /
342	if (( $# )); then
343		\\builtin read -raN-1 s <<<"$*"
344		\\builtin unset s[${#s[*]}-1]
345	else
346		\\builtin read -raN-1 s
347	fi
348	\\builtin typeset -i i=0 n=${#s[*]} v
349
350	while (( i < n )); do
351		(( v = s[i++] << 16 ))
352		(( v |= s[i++] << 8 ))
353		(( v |= s[i++] ))
354		t+=${table[v >> 18]}${table[v >> 12 & 63]}
355		c=${table[v >> 6 & 63]}
356		if (( i <= n )); then
357			t+=$c${table[v & 63]}
358		elif (( i == n + 1 )); then
359			t+=$c=
360		else
361			t+===
362		fi
363		if (( ${#t} == 76 || i >= n )); then
364			\\builtin print -r $t
365			t=
366		fi
367	done
368}
369
370# Better Avalanche for the Jenkins Hash
371\\builtin typeset -Z11 -Uui16 Lbafh_v
372function Lbafh_init {
373	Lbafh_v=0
374}
375function Lbafh_add {
376	\\builtin set +U
377	\\builtin typeset s
378	if (( $# )); then
379		\\builtin read -raN-1 s <<<"$*"
380		\\builtin unset s[${#s[*]}-1]
381	else
382		\\builtin read -raN-1 s
383	fi
384	\\builtin typeset -i i=0 n=${#s[*]}
385
386	while (( i < n )); do
387		((# Lbafh_v = (Lbafh_v + s[i++] + 1) * 1025 ))
388		((# Lbafh_v ^= Lbafh_v >> 6 ))
389	done
390}
391function Lbafh_finish {
392	\\builtin typeset -Ui t
393
394	((# t = (((Lbafh_v >> 7) & 0x01010101) * 0x1B) ^ \
395	    ((Lbafh_v << 1) & 0xFEFEFEFE) ))
396	((# Lbafh_v = t ^ (t ^> 8) ^ (Lbafh_v ^> 8) ^ \
397	    (Lbafh_v ^> 16) ^ (Lbafh_v ^> 24) ))
398	\:
399}
400
401# strip comments (and leading/trailing whitespace if IFS is set) from
402# any file(s) given as argument, or stdin if none, and spew to stdout
403function Lstripcom {
404	\\builtin set -o noglob
405	\\builtin cat "$@" | while \\builtin read _line; do
406		_line=${_line%%#*}
407		[[ -n $_line ]] && \\builtin print -r -- $_line
408	done
409}
410
411# toggle built-in aliases and utilities, and aliases and functions from mkshrc
412function enable {
413	\\builtin typeset doprnt=0 mode=1 x y z rv=0
414	\\builtin typeset b_alias i_alias i_func nalias=0 nfunc=0 i_all
415	\\builtin set -A b_alias
416	\\builtin set -A i_alias
417	\\builtin set -A i_func
418
419	# accumulate mksh built-in aliases, in ASCIIbetical order
420	i_alias[nalias]=autoload; b_alias[nalias++]='\\builtin typeset -fu'
421	i_alias[nalias]=functions; b_alias[nalias++]='\\builtin typeset -f'
422	i_alias[nalias]=hash; b_alias[nalias++]='\\builtin alias -t'
423	i_alias[nalias]=history; b_alias[nalias++]='\\builtin fc -l'
424	i_alias[nalias]=integer; b_alias[nalias++]='\\builtin typeset -i'
425	i_alias[nalias]=local; b_alias[nalias++]='\\builtin typeset'
426	i_alias[nalias]=login; b_alias[nalias++]='\\builtin exec login'
427	i_alias[nalias]=nameref; b_alias[nalias++]='\\builtin typeset -n'
428	i_alias[nalias]=nohup; b_alias[nalias++]='nohup '
429	i_alias[nalias]=r; b_alias[nalias++]='\\builtin fc -e -'
430	i_alias[nalias]=type; b_alias[nalias++]='\\builtin whence -v'
431
432	# accumulate mksh built-in utilities, in definition order, even ifndef
433	i_func[nfunc++]=.
434	i_func[nfunc++]=:
435	i_func[nfunc++]='['
436	i_func[nfunc++]=alias
437	i_func[nfunc++]=break
438	# \\builtin cannot, by design, be overridden
439	i_func[nfunc++]=builtin
440	i_func[nfunc++]=cat
441	i_func[nfunc++]=cd
442	i_func[nfunc++]=chdir
443	i_func[nfunc++]=command
444	i_func[nfunc++]=continue
445	i_func[nfunc++]=echo
446	i_func[nfunc++]=eval
447	i_func[nfunc++]=exec
448	i_func[nfunc++]=exit
449	i_func[nfunc++]=export
450	i_func[nfunc++]=false
451	i_func[nfunc++]=fc
452	i_func[nfunc++]=getopts
453	i_func[nfunc++]=global
454	i_func[nfunc++]=jobs
455	i_func[nfunc++]=kill
456	i_func[nfunc++]=let
457	i_func[nfunc++]=print
458	i_func[nfunc++]=pwd
459	i_func[nfunc++]=read
460	i_func[nfunc++]=readonly
461	i_func[nfunc++]=realpath
462	i_func[nfunc++]=rename
463	i_func[nfunc++]=return
464	i_func[nfunc++]=set
465	i_func[nfunc++]=shift
466	i_func[nfunc++]=source
467	i_func[nfunc++]=suspend
468	i_func[nfunc++]=test
469	i_func[nfunc++]=times
470	i_func[nfunc++]=trap
471	i_func[nfunc++]=true
472	i_func[nfunc++]=typeset
473	i_func[nfunc++]=ulimit
474	i_func[nfunc++]=umask
475	i_func[nfunc++]=unalias
476	i_func[nfunc++]=unset
477	i_func[nfunc++]=wait
478	i_func[nfunc++]=whence
479	i_func[nfunc++]=bg
480	i_func[nfunc++]=fg
481	i_func[nfunc++]=bind
482	i_func[nfunc++]=mknod
483	i_func[nfunc++]=printf
484	i_func[nfunc++]=sleep
485	i_func[nfunc++]=domainname
486	i_func[nfunc++]=extproc
487
488	# accumulate aliases from dot.mkshrc, in definition order
489	i_alias[nalias]=l; b_alias[nalias++]='ls -F'
490	i_alias[nalias]=la; b_alias[nalias++]='l -a'
491	i_alias[nalias]=ll; b_alias[nalias++]='l -l'
492	i_alias[nalias]=lo; b_alias[nalias++]='l -alo'
493	i_alias[nalias]=doch; b_alias[nalias++]='sudo mksh -c "$(\\builtin fc -ln -1)"'
494	i_alias[nalias]=rot13; b_alias[nalias++]='tr abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
495	i_alias[nalias]=cls; b_alias[nalias++]='\\builtin print -n \\ec'
496
497	# accumulate functions from dot.mkshrc, in definition order
498	i_func[nfunc++]=setenv
499	i_func[nfunc++]=smores
500	i_func[nfunc++]=hd
501	i_func[nfunc++]=hd_mksh
502	i_func[nfunc++]=chpwd
503	i_func[nfunc++]=cd
504	i_func[nfunc++]=cd_csh
505	i_func[nfunc++]=dirs
506	i_func[nfunc++]=popd
507	i_func[nfunc++]=pushd
508	i_func[nfunc++]=Lb64decode
509	i_func[nfunc++]=Lb64encode
510	i_func[nfunc++]=Lbafh_init
511	i_func[nfunc++]=Lbafh_add
512	i_func[nfunc++]=Lbafh_finish
513	i_func[nfunc++]=Lstripcom
514	i_func[nfunc++]=enable
515
516	# collect all identifiers, sorted ASCIIbetically
517	\\builtin set -sA i_all -- "${i_alias[@]}" "${i_func[@]}"
518
519	# handle options, we don't do dynamic loading
520	while \\builtin getopts "adf:nps" x; do
521		case $x {
522		(a)
523			mode=-1
524			;;
525		(d)
526			# deliberately causing an error, like bash-static
527			;|
528		(f)
529			\\builtin print -ru2 enable: dynamic loading not available
530			\\builtin return 2
531			;;
532		(n)
533			mode=0
534			;;
535		(p)
536			doprnt=1
537			;;
538		(s)
539			\\builtin set -sA i_all -- . : break continue eval \
540			    exec exit export readonly return set shift times \
541			    trap unset
542			;;
543		(*)
544			\\builtin print -ru2 enable: usage: \
545			    "enable [-adnps] [-f filename] [name ...]"
546			return 2
547			;;
548		}
549	done
550	\\builtin shift $((OPTIND - 1))
551
552	# display builtins enabled/disabled/all/special?
553	if (( doprnt || ($# == 0) )); then
554		for x in "${i_all[@]}"; do
555			y=$(\\builtin alias "$x") || y=
556			[[ $y = "$x='\\\\builtin whence -p $x >/dev/null || (\\\\builtin print -r mksh: $x: not found; \\\\builtin exit 127) && \$(\\\\builtin whence -p $x)'" ]]; z=$?
557			case $mode:$z {
558			(-1:0|0:0)
559				\\builtin print -r -- "enable -n $x"
560				;;
561			(-1:1|1:1)
562				\\builtin print -r -- "enable $x"
563				;;
564			}
565		done
566		\\builtin return 0
567	fi
568
569	for x in "$@"; do
570		z=0
571		for y in "${i_alias[@]}" "${i_func[@]}"; do
572			[[ $x = "$y" ]] || \\builtin continue
573			z=1
574			\\builtin break
575		done
576		if (( !z )); then
577			\\builtin print -ru2 enable: "$x": not a shell builtin
578			rv=1
579			\\builtin continue
580		fi
581		if (( !mode )); then
582			# disable this
583			\\builtin alias "$x=\\\\builtin whence -p $x >/dev/null || (\\\\builtin print -r mksh: $x: not found; \\\\builtin exit 127) && \$(\\\\builtin whence -p $x)"
584		else
585			# find out if this is an alias or not, first
586			z=0
587			y=-1
588			while (( ++y < nalias )); do
589				[[ $x = "${i_alias[y]}" ]] || \\builtin continue
590				z=1
591				\\builtin break
592			done
593			if (( z )); then
594				# re-enable the original alias body
595				\\builtin alias "$x=${b_alias[y]}"
596			else
597				# re-enable the original utility/function
598				\\builtin unalias "$x"
599			fi
600		fi
601	done
602	\\builtin return $rv
603}
604
605\: place customisations below this line
606
607# some defaults follow — you are supposed to adjust these to your
608# liking; by default we add ~/.etc/bin and ~/bin (whichever exist)
609# to $PATH, set $SHELL to mksh, set some defaults for man and less
610# and show a few more possible things for users to begin moving in
611
612for p in ~/.etc/bin ~/bin; do
613	[[ -d $p/. ]] || \\builtin continue
614	[[ $PATHSEP$PATH$PATHSEP = *"$PATHSEP$p$PATHSEP"* ]] || \
615	    PATH=$p$PATHSEP$PATH
616done
617
618\\builtin export SHELL=$MKSH MANWIDTH=80 LESSHISTFILE=-
619\\builtin alias cls='\\builtin print -n \\ec'
620
621#\\builtin unset LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_IDENTIFICATION LC_MONETARY \
622#    LC_NAME LC_NUMERIC LC_TELEPHONE LC_TIME
623#p=en_GB.UTF-8
624#\\builtin export LANG=C LC_CTYPE=$p LC_MEASUREMENT=$p LC_MESSAGES=$p LC_PAPER=$p
625#\\builtin set -U
626
627\\builtin unset p
628
629\: place customisations above this line
630