replace typeset with local, as style(9) now mandates
(keep globals for a while, until it’s widespread, though) since we don’t export PS1 any longer, no need to stay AT&T ksh compatible
This commit is contained in:
		
							
								
								
									
										48
									
								
								dot.mkshrc
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								dot.mkshrc
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| # $Id$ | ||||
| # $MirOS: src/bin/mksh/dot.mkshrc,v 1.61 2011/07/03 23:26:47 tg Exp $ | ||||
| # $MirOS: src/bin/mksh/dot.mkshrc,v 1.62 2011/07/05 20:19:17 tg Exp $ | ||||
| #- | ||||
| # Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 | ||||
| #	Thorsten Glaser <tg@mirbsd.org> | ||||
| @@ -25,12 +25,12 @@ | ||||
| [[ $HOSTNAME = @(localhost|*([	 ])) ]] && HOSTNAME=$(ulimit -c 0;hostname 2>&-) | ||||
| : ${HOSTNAME:=nil}; if (( USER_ID )); then PS1='$'; else PS1='#'; fi | ||||
| function precmd { | ||||
| 	typeset e=$? | ||||
| 	local e=$? | ||||
|  | ||||
| 	(( e )) && print -n "$e|" | ||||
| } | ||||
| PS1=' | ||||
| $(precmd)${USER:=$(ulimit -c 0;id -un 2>&-||print \?)}@${HOSTNAME%%.*}:$( | ||||
| $(precmd)${USER:=$(ulimit -c 0;id -un 2>&-||print \?)}@${HOSTNAME%%.*}:$( | ||||
| 	local d=${PWD:-?} n p=~; [[ $p = ?(*/) ]] || d=${d/#$p/~} | ||||
| 	(( (${%d}>0 ? ${%d}: ${#d}) > (n = (COLUMNS/3<7 ? 7: COLUMNS/3)) )) && { | ||||
| 	d=${d:(-n)}; p=...; } || p=; print -nr -- "$p$d") '"$PS1 " | ||||
| @@ -64,7 +64,7 @@ function cd { | ||||
| 	builtin cd "$@" | ||||
| 	chpwd "$@" | ||||
| } | ||||
| function cd_csh { | ||||
| function cd_csh { | ||||
| 	local d t=${1/#~/$DIRSTACKBASE} | ||||
|  | ||||
| 	if ! d=$(builtin cd "$t" 2>&1); then | ||||
| @@ -73,8 +73,8 @@ function cd_csh { | ||||
| 	fi | ||||
| 	cd "$t" | ||||
| } | ||||
| function dirs { | ||||
| 	typeset d dwidth | ||||
| function dirs { | ||||
| 	local d dwidth | ||||
| 	local -i isnoglob=0 fl=0 fv=0 fn=0 cpos=0 | ||||
|  | ||||
| 	[[ $(set +o) == *@(-o noglob)@(| *) ]] && isnoglob=1 | ||||
| @@ -120,8 +120,8 @@ function dirs { | ||||
| 	(( isnoglob )) || set +o noglob | ||||
| 	return 0 | ||||
| } | ||||
| function popd { | ||||
| 	typeset d fa | ||||
| function popd { | ||||
| 	local d fa | ||||
| 	local -i isnoglob=0 n=1 | ||||
|  | ||||
| 	[[ $(set +o) == *@(-o noglob)@(| *) ]] && isnoglob=1 | ||||
| @@ -159,8 +159,8 @@ function popd { | ||||
| 	(( isnoglob )) || set +o noglob | ||||
| 	dirs $fa | ||||
| } | ||||
| function pushd { | ||||
| 	typeset d fa | ||||
| function pushd { | ||||
| 	local d fa | ||||
| 	local -i isnoglob=0 n=1 | ||||
|  | ||||
| 	[[ $(set +o) == *@(-o noglob)@(| *) ]] && isnoglob=1 | ||||
| @@ -206,7 +206,7 @@ function pushd { | ||||
| } | ||||
|  | ||||
| # pager (not control character safe) | ||||
| function smores { | ||||
| function smores { | ||||
| 	local dummy line llen curlin=0 | ||||
|  | ||||
| 	cat "$@" | while IFS= read -r line; do | ||||
| @@ -224,12 +224,12 @@ function smores { | ||||
| } | ||||
|  | ||||
| # base64 encoder and decoder, RFC compliant, NUL safe | ||||
| function Lb64decode { | ||||
| function Lb64decode { | ||||
| 	[[ -o utf8-mode ]]; local u=$? | ||||
| 	set +U | ||||
| 	set +U | ||||
| 	local c s="$*" t= | ||||
| 	[[ -n $s ]] || { s=$(cat;print x); s=${s%x}; } | ||||
| 	typeset -i i=0 n=${#s} p=0 v x | ||||
| 	[[ -n $s ]] || { s=$(cat;print x); s=${s%x}; } | ||||
| 	local -i i=0 n=${#s} p=0 v x | ||||
| 	local -i16 o | ||||
|  | ||||
| 	while (( i < n )); do | ||||
| @@ -260,16 +260,16 @@ function Lb64decode { | ||||
|  | ||||
| set -A Lb64encode_code -- 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 \ | ||||
|     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 + / | ||||
| function Lb64encode { | ||||
| function Lb64encode { | ||||
| 	[[ -o utf8-mode ]]; local u=$? | ||||
| 	set +U | ||||
| 	set +U | ||||
| 	local c s t | ||||
| 	if (( $# )); then | ||||
| 		read -raN-1 s <<<"$*" | ||||
| 		unset s[${#s[*]}-1] | ||||
| 	else | ||||
| 		read -raN-1 s | ||||
| 	fi | ||||
| 	fi | ||||
| 	local -i i=0 n=${#s[*]} j v | ||||
|  | ||||
| 	while (( i < n )); do | ||||
| @@ -297,16 +297,16 @@ function Lb64encode { | ||||
|  | ||||
| # DJB cdb hash (not via stdio, for speed) | ||||
| typeset -Z11 -Uui16 Lcdbhash_result | ||||
| function Lcdbhash_add { | ||||
| function Lcdbhash_add { | ||||
| 	[[ -o utf8-mode ]]; local u=$? | ||||
| 	set +U | ||||
| 	set +U | ||||
| 	local s | ||||
| 	if (( $# )); then | ||||
| 		read -raN-1 s <<<"$*" | ||||
| 		unset s[${#s[*]}-1] | ||||
| 	else | ||||
| 		read -raN-1 s | ||||
| 	fi | ||||
| 	fi | ||||
| 	local -i i=0 n=${#s[*]} | ||||
|  | ||||
| 	while (( i < n )); do | ||||
| @@ -323,16 +323,16 @@ function Lcdbhash { | ||||
|  | ||||
| # Jenkins one-at-a-time hash (not via stdio, for speed) | ||||
| typeset -Z11 -Uui16 Loaathash_result | ||||
| function Loaathash_add { | ||||
| function Loaathash_add { | ||||
| 	[[ -o utf8-mode ]]; local u=$? | ||||
| 	set +U | ||||
| 	set +U | ||||
| 	local s | ||||
| 	if (( $# )); then | ||||
| 		read -raN-1 s <<<"$*" | ||||
| 		unset s[${#s[*]}-1] | ||||
| 	else | ||||
| 		read -raN-1 s | ||||
| 	fi | ||||
| 	fi | ||||
| 	local -i i=0 n=${#s[*]} | ||||
|  | ||||
| 	while (( i < n )); do | ||||
|   | ||||
							
								
								
									
										8
									
								
								mksh.1
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								mksh.1
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| .\" $MirOS: src/bin/mksh/mksh.1,v 1.266 2011/07/02 17:57:24 tg Exp $ | ||||
| .\" $MirOS: src/bin/mksh/mksh.1,v 1.267 2011/07/05 20:19:18 tg Exp $ | ||||
| .\" $OpenBSD: ksh.1,v 1.140 2011/04/23 10:14:59 sobrado Exp $ | ||||
| .\"- | ||||
| .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, | ||||
| @@ -72,7 +72,7 @@ | ||||
| .\" with -mandoc, it might implement .Mx itself, but we want to | ||||
| .\" use our own definition. And .Dd must come *first*, always. | ||||
| .\" | ||||
| .Dd $Mdocdate: July 2 2011 $ | ||||
| .Dd $Mdocdate: July 5 2011 $ | ||||
| .\" | ||||
| .\" Check which macro package we use | ||||
| .\" | ||||
| @@ -1352,6 +1352,7 @@ The construct | ||||
| is also recognised; the old and new values are immediately concatenated. | ||||
| The fourth way of setting a parameter is with the | ||||
| .Ic export , | ||||
| .Ic global , | ||||
| .Ic readonly , | ||||
| and | ||||
| .Ic typeset | ||||
| @@ -2045,6 +2046,7 @@ In parameter assignments | ||||
| in the arguments of | ||||
| .Ic alias , | ||||
| .Ic export , | ||||
| .Ic global , | ||||
| .Ic readonly , | ||||
| and | ||||
| .Ic typeset ) , | ||||
| @@ -2848,7 +2850,7 @@ Additional | ||||
| .Nm | ||||
| special commands | ||||
| .Pp | ||||
| .Ic builtin , times , typeset | ||||
| .Ic builtin , global , times , typeset | ||||
| .Pp | ||||
| Very special commands | ||||
| .Pq non-POSIX | ||||
|   | ||||
		Reference in New Issue
	
	Block a user