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