“local x=$1” is supposed to not field-split and so
This commit is contained in:
parent
532af35304
commit
0d72355038
83
check.t
83
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.684 2015/03/08 22:54:31 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.685 2015/03/14 05:23:12 tg Exp $
|
||||||
# -*- mode: sh -*-
|
# -*- mode: sh -*-
|
||||||
#-
|
#-
|
||||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
@ -30,7 +30,7 @@
|
|||||||
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R50 2015/03/08
|
@(#)MIRBSD KSH R50 2015/03/13
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -39,7 +39,7 @@ name: KSH_VERSION
|
|||||||
category: shell:legacy-no
|
category: shell:legacy-no
|
||||||
---
|
---
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)LEGACY KSH R50 2015/03/08
|
@(#)LEGACY KSH R50 2015/03/13
|
||||||
description:
|
description:
|
||||||
Check version of legacy shell.
|
Check version of legacy shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -257,6 +257,19 @@ stdin:
|
|||||||
expected-stdout:
|
expected-stdout:
|
||||||
hello world
|
hello world
|
||||||
---
|
---
|
||||||
|
name: alias-11
|
||||||
|
description:
|
||||||
|
Check that special argument handling still applies with escaped aliases
|
||||||
|
stdin:
|
||||||
|
alias local='\typeset'
|
||||||
|
function foo {
|
||||||
|
local x=$1 y=z
|
||||||
|
print -r -- "$x,$y"
|
||||||
|
}
|
||||||
|
foo 'bar - baz'
|
||||||
|
expected-stdout:
|
||||||
|
bar - baz,z
|
||||||
|
---
|
||||||
name: arith-lazy-1
|
name: arith-lazy-1
|
||||||
description:
|
description:
|
||||||
Check that only one side of ternary operator is evaluated
|
Check that only one side of ternary operator is evaluated
|
||||||
@ -7370,14 +7383,14 @@ stdin:
|
|||||||
alias
|
alias
|
||||||
typeset -f
|
typeset -f
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
autoload='\builtin typeset -fu'
|
autoload='\typeset -fu'
|
||||||
functions='\builtin typeset -f'
|
functions='\typeset -f'
|
||||||
hash='\builtin alias -t'
|
hash='\builtin alias -t'
|
||||||
history='\builtin fc -l'
|
history='\builtin fc -l'
|
||||||
integer='\builtin typeset -i'
|
integer='\typeset -i'
|
||||||
local='\builtin typeset'
|
local='\typeset'
|
||||||
login='\exec login'
|
login='\exec login'
|
||||||
nameref='\builtin typeset -n'
|
nameref='\typeset -n'
|
||||||
nohup='nohup '
|
nohup='nohup '
|
||||||
r='\builtin fc -e -'
|
r='\builtin fc -e -'
|
||||||
source='PATH=$PATH:. \command .'
|
source='PATH=$PATH:. \command .'
|
||||||
@ -7392,14 +7405,14 @@ stdin:
|
|||||||
alias
|
alias
|
||||||
typeset -f
|
typeset -f
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
autoload='\builtin typeset -fu'
|
autoload='\typeset -fu'
|
||||||
functions='\builtin typeset -f'
|
functions='\typeset -f'
|
||||||
hash='\builtin alias -t'
|
hash='\builtin alias -t'
|
||||||
history='\builtin fc -l'
|
history='\builtin fc -l'
|
||||||
integer='\builtin typeset -i'
|
integer='\typeset -i'
|
||||||
local='\builtin typeset'
|
local='\typeset'
|
||||||
login='\exec login'
|
login='\exec login'
|
||||||
nameref='\builtin typeset -n'
|
nameref='\typeset -n'
|
||||||
nohup='nohup '
|
nohup='nohup '
|
||||||
r='\builtin fc -e -'
|
r='\builtin fc -e -'
|
||||||
source='PATH=$PATH:. \command .'
|
source='PATH=$PATH:. \command .'
|
||||||
@ -7414,14 +7427,14 @@ stdin:
|
|||||||
alias
|
alias
|
||||||
typeset -f
|
typeset -f
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
autoload='\builtin typeset -fu'
|
autoload='\typeset -fu'
|
||||||
functions='\builtin typeset -f'
|
functions='\typeset -f'
|
||||||
hash='\builtin alias -t'
|
hash='\builtin alias -t'
|
||||||
history='\builtin fc -l'
|
history='\builtin fc -l'
|
||||||
integer='\builtin typeset -i'
|
integer='\typeset -i'
|
||||||
local='\builtin typeset'
|
local='\typeset'
|
||||||
login='\exec login'
|
login='\exec login'
|
||||||
nameref='\builtin typeset -n'
|
nameref='\typeset -n'
|
||||||
nohup='nohup '
|
nohup='nohup '
|
||||||
r='\builtin fc -e -'
|
r='\builtin fc -e -'
|
||||||
source='PATH=$PATH:. \command .'
|
source='PATH=$PATH:. \command .'
|
||||||
@ -7437,14 +7450,14 @@ stdin:
|
|||||||
./sh -c 'alias; typeset -f'
|
./sh -c 'alias; typeset -f'
|
||||||
rm -f sh
|
rm -f sh
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
autoload='\builtin typeset -fu'
|
autoload='\typeset -fu'
|
||||||
functions='\builtin typeset -f'
|
functions='\typeset -f'
|
||||||
hash='\builtin alias -t'
|
hash='\builtin alias -t'
|
||||||
history='\builtin fc -l'
|
history='\builtin fc -l'
|
||||||
integer='\builtin typeset -i'
|
integer='\typeset -i'
|
||||||
local='\builtin typeset'
|
local='\typeset'
|
||||||
login='\exec login'
|
login='\exec login'
|
||||||
nameref='\builtin typeset -n'
|
nameref='\typeset -n'
|
||||||
nohup='nohup '
|
nohup='nohup '
|
||||||
r='\builtin fc -e -'
|
r='\builtin fc -e -'
|
||||||
source='PATH=$PATH:. \command .'
|
source='PATH=$PATH:. \command .'
|
||||||
@ -7460,14 +7473,14 @@ stdin:
|
|||||||
alias
|
alias
|
||||||
typeset -f
|
typeset -f
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
autoload='\builtin typeset -fu'
|
autoload='\typeset -fu'
|
||||||
functions='\builtin typeset -f'
|
functions='\typeset -f'
|
||||||
hash='\builtin alias -t'
|
hash='\builtin alias -t'
|
||||||
history='\builtin fc -l'
|
history='\builtin fc -l'
|
||||||
integer='\builtin typeset -i'
|
integer='\typeset -i'
|
||||||
local='\builtin typeset'
|
local='\typeset'
|
||||||
login='\exec login'
|
login='\exec login'
|
||||||
nameref='\builtin typeset -n'
|
nameref='\typeset -n'
|
||||||
nohup='nohup '
|
nohup='nohup '
|
||||||
r='\builtin fc -e -'
|
r='\builtin fc -e -'
|
||||||
source='PATH=$PATH:. \command .'
|
source='PATH=$PATH:. \command .'
|
||||||
@ -7482,14 +7495,14 @@ stdin:
|
|||||||
./sh -c 'alias; typeset -f'
|
./sh -c 'alias; typeset -f'
|
||||||
rm -f sh
|
rm -f sh
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
autoload='\builtin typeset -fu'
|
autoload='\typeset -fu'
|
||||||
functions='\builtin typeset -f'
|
functions='\typeset -f'
|
||||||
hash='\builtin alias -t'
|
hash='\builtin alias -t'
|
||||||
history='\builtin fc -l'
|
history='\builtin fc -l'
|
||||||
integer='\builtin typeset -i'
|
integer='\typeset -i'
|
||||||
local='\builtin typeset'
|
local='\typeset'
|
||||||
login='\exec login'
|
login='\exec login'
|
||||||
nameref='\builtin typeset -n'
|
nameref='\typeset -n'
|
||||||
nohup='nohup '
|
nohup='nohup '
|
||||||
r='\builtin fc -e -'
|
r='\builtin fc -e -'
|
||||||
source='PATH=$PATH:. \command .'
|
source='PATH=$PATH:. \command .'
|
||||||
@ -7550,8 +7563,8 @@ stdin:
|
|||||||
:|| local() { :; }
|
:|| local() { :; }
|
||||||
alias local
|
alias local
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
local='\builtin typeset'
|
local='\typeset'
|
||||||
local='\builtin typeset'
|
local='\typeset'
|
||||||
---
|
---
|
||||||
name: arrays-1
|
name: arrays-1
|
||||||
description:
|
description:
|
||||||
|
62
dot.mkshrc
62
dot.mkshrc
@ -1,5 +1,5 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.93 2015/03/08 23:50:00 tg Exp $
|
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.94 2015/03/14 05:23:14 tg Exp $
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
|
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012, 2013, 2014, 2015
|
# 2011, 2012, 2013, 2014, 2015
|
||||||
@ -32,14 +32,14 @@ PS1='#'; (( USER_ID )) && PS1='$'; [[ ${HOSTNAME:=$(\ulimit -c 0; hostname -s \
|
|||||||
2>/dev/null)} = *([ ]|localhost) ]] && HOSTNAME=$(\ulimit -c 0; hostname \
|
2>/dev/null)} = *([ ]|localhost) ]] && HOSTNAME=$(\ulimit -c 0; hostname \
|
||||||
2>/dev/null); \: ${EDITOR:=/bin/ed} ${HOSTNAME:=nil} ${TERM:=vt100}
|
2>/dev/null); \: ${EDITOR:=/bin/ed} ${HOSTNAME:=nil} ${TERM:=vt100}
|
||||||
\: ${MKSH:=$(\builtin whence -p mksh)}; PS4='[$EPOCHREALTIME] '; PS1=$'\001\r''${|
|
\: ${MKSH:=$(\builtin whence -p mksh)}; PS4='[$EPOCHREALTIME] '; PS1=$'\001\r''${|
|
||||||
\builtin typeset e=$?
|
\typeset e=$?
|
||||||
|
|
||||||
(( e )) && REPLY+="$e|"
|
(( e )) && REPLY+="$e|"
|
||||||
REPLY+=${USER:=$(\ulimit -c 0; id -un 2>/dev/null || \echo \?)}
|
REPLY+=${USER:=$(\ulimit -c 0; id -un 2>/dev/null || \echo \?)}
|
||||||
REPLY+=@${HOSTNAME%%.*}:
|
REPLY+=@${HOSTNAME%%.*}:
|
||||||
|
|
||||||
\builtin typeset d=${PWD:-?} p=~; [[ $p = ?(*/) ]] || d=${d/#$p/~}
|
\typeset d=${PWD:-?} p=~; [[ $p = ?(*/) ]] || d=${d/#$p/~}
|
||||||
\builtin typeset m=${%d} n p=...; (( m > 0 )) || m=${#d}
|
\typeset m=${%d} n p=...; (( m > 0 )) || m=${#d}
|
||||||
(( m > (n = (COLUMNS/3 < 7 ? 7 : COLUMNS/3)) )) && d=${d:(-n)} || p=
|
(( m > (n = (COLUMNS/3 < 7 ? 7 : COLUMNS/3)) )) && d=${d:(-n)} || p=
|
||||||
REPLY+=$p$d
|
REPLY+=$p$d
|
||||||
|
|
||||||
@ -62,12 +62,12 @@ if \command -v hd >/dev/null; then \:; elif \command -v hexdump >/dev/null; then
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
function hd {
|
function hd {
|
||||||
\builtin typeset -Uui16 -Z11 pos=0
|
\typeset -Uui16 -Z11 pos=0
|
||||||
\builtin typeset -Uui16 -Z5 hv=2147483647
|
\typeset -Uui16 -Z5 hv=2147483647
|
||||||
\builtin typeset dasc line i
|
\typeset dasc line i
|
||||||
|
|
||||||
\cat "$@" | { \set +U; if \read -arN -1 line; then
|
\cat "$@" | { \set +U; if \read -arN -1 line; then
|
||||||
\builtin typeset -i1 'line[*]'
|
\typeset -i1 'line[*]'
|
||||||
i=0
|
i=0
|
||||||
while (( i < ${#line[*]} )); do
|
while (( i < ${#line[*]} )); do
|
||||||
hv=${line[i++]}
|
hv=${line[i++]}
|
||||||
@ -109,7 +109,7 @@ function cd {
|
|||||||
\chpwd "$@"
|
\chpwd "$@"
|
||||||
}
|
}
|
||||||
function cd_csh {
|
function cd_csh {
|
||||||
\builtin typeset d t=${1/#~/$DIRSTACKBASE}
|
\typeset d t=${1/#~/$DIRSTACKBASE}
|
||||||
|
|
||||||
if ! d=$(\builtin cd "$t" 2>&1); then
|
if ! d=$(\builtin cd "$t" 2>&1); then
|
||||||
\builtin print -u2 "${1}: ${d##*cd: $t: }."
|
\builtin print -u2 "${1}: ${d##*cd: $t: }."
|
||||||
@ -118,8 +118,8 @@ function cd_csh {
|
|||||||
\cd "$t"
|
\cd "$t"
|
||||||
}
|
}
|
||||||
function dirs {
|
function dirs {
|
||||||
\builtin typeset d dwidth
|
\typeset d dwidth
|
||||||
\builtin typeset -i fl=0 fv=0 fn=0 cpos=0
|
\typeset -i fl=0 fv=0 fn=0 cpos=0
|
||||||
|
|
||||||
while \getopts ":lvn" d; do
|
while \getopts ":lvn" d; do
|
||||||
case $d {
|
case $d {
|
||||||
@ -162,8 +162,8 @@ function dirs {
|
|||||||
\return 0
|
\return 0
|
||||||
}
|
}
|
||||||
function popd {
|
function popd {
|
||||||
\builtin typeset d fa
|
\typeset d fa
|
||||||
\builtin typeset -i n=1
|
\typeset -i n=1
|
||||||
|
|
||||||
while \getopts ":0123456789lvn" d; do
|
while \getopts ":0123456789lvn" d; do
|
||||||
case $d {
|
case $d {
|
||||||
@ -198,8 +198,8 @@ function popd {
|
|||||||
\dirs $fa
|
\dirs $fa
|
||||||
}
|
}
|
||||||
function pushd {
|
function pushd {
|
||||||
\builtin typeset d fa
|
\typeset d fa
|
||||||
\builtin typeset -i n=1
|
\typeset -i n=1
|
||||||
|
|
||||||
while \getopts ":0123456789lvn" d; do
|
while \getopts ":0123456789lvn" d; do
|
||||||
case $d {
|
case $d {
|
||||||
@ -263,11 +263,11 @@ 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 ]]; \builtin typeset u=$? c s="$*" t
|
[[ -o utf8-mode ]]; \typeset u=$? c s="$*" t
|
||||||
\set +U
|
\set +U
|
||||||
[[ -n $s ]] || { s=$(\cat; \builtin print x); s=${s%x}; }
|
[[ -n $s ]] || { s=$(\cat; \builtin print x); s=${s%x}; }
|
||||||
\builtin typeset -i i=0 j=0 n=${#s} p=0 v x
|
\typeset -i i=0 j=0 n=${#s} p=0 v x
|
||||||
\builtin typeset -i16 o
|
\typeset -i16 o
|
||||||
|
|
||||||
while (( i < n )); do
|
while (( i < n )); do
|
||||||
c=${s:(i++):1}
|
c=${s:(i++):1}
|
||||||
@ -301,7 +301,7 @@ 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 ]]; \builtin typeset u=$? c s t
|
[[ -o utf8-mode ]]; \typeset u=$? c s t
|
||||||
\set +U
|
\set +U
|
||||||
if (( $# )); then
|
if (( $# )); then
|
||||||
\read -raN-1 s <<<"$*"
|
\read -raN-1 s <<<"$*"
|
||||||
@ -309,7 +309,7 @@ function Lb64encode {
|
|||||||
else
|
else
|
||||||
\read -raN-1 s
|
\read -raN-1 s
|
||||||
fi
|
fi
|
||||||
\builtin typeset -i i=0 n=${#s[*]} j v
|
\typeset -i i=0 n=${#s[*]} j v
|
||||||
|
|
||||||
while (( i < n )); do
|
while (( i < n )); do
|
||||||
(( v = s[i++] << 16 ))
|
(( v = s[i++] << 16 ))
|
||||||
@ -335,12 +335,12 @@ function Lb64encode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Better Avalanche for the Jenkins Hash
|
# Better Avalanche for the Jenkins Hash
|
||||||
\builtin typeset -Z11 -Uui16 Lbafh_v
|
\typeset -Z11 -Uui16 Lbafh_v
|
||||||
function Lbafh_init {
|
function Lbafh_init {
|
||||||
Lbafh_v=0
|
Lbafh_v=0
|
||||||
}
|
}
|
||||||
function Lbafh_add {
|
function Lbafh_add {
|
||||||
[[ -o utf8-mode ]]; \builtin typeset u=$? s
|
[[ -o utf8-mode ]]; \typeset u=$? s
|
||||||
\set +U
|
\set +U
|
||||||
if (( $# )); then
|
if (( $# )); then
|
||||||
\read -raN-1 s <<<"$*"
|
\read -raN-1 s <<<"$*"
|
||||||
@ -348,7 +348,7 @@ function Lbafh_add {
|
|||||||
else
|
else
|
||||||
\read -raN-1 s
|
\read -raN-1 s
|
||||||
fi
|
fi
|
||||||
\builtin typeset -i i=0 n=${#s[*]}
|
\typeset -i i=0 n=${#s[*]}
|
||||||
|
|
||||||
while (( i < n )); do
|
while (( i < n )); do
|
||||||
((# Lbafh_v = (Lbafh_v + s[i++] + 1) * 1025 ))
|
((# Lbafh_v = (Lbafh_v + s[i++] + 1) * 1025 ))
|
||||||
@ -358,7 +358,7 @@ function Lbafh_add {
|
|||||||
(( u )) || \set -U
|
(( u )) || \set -U
|
||||||
}
|
}
|
||||||
function Lbafh_finish {
|
function Lbafh_finish {
|
||||||
\builtin typeset -Ui t
|
\typeset -Ui t
|
||||||
|
|
||||||
((# t = (((Lbafh_v >> 7) & 0x01010101) * 0x1B) ^ \
|
((# t = (((Lbafh_v >> 7) & 0x01010101) * 0x1B) ^ \
|
||||||
((Lbafh_v << 1) & 0xFEFEFEFE) ))
|
((Lbafh_v << 1) & 0xFEFEFEFE) ))
|
||||||
@ -383,21 +383,21 @@ function setenv {
|
|||||||
|
|
||||||
# toggle built-in aliases and utilities, and aliases and functions from here
|
# toggle built-in aliases and utilities, and aliases and functions from here
|
||||||
function enable {
|
function enable {
|
||||||
\builtin typeset doprnt=0 mode=1 x y z rv=0
|
\typeset doprnt=0 mode=1 x y z rv=0
|
||||||
\builtin typeset b_alias i_alias i_func nalias=0 nfunc=0 i_all
|
\typeset b_alias i_alias i_func nalias=0 nfunc=0 i_all
|
||||||
\set -A b_alias
|
\set -A b_alias
|
||||||
\set -A i_alias
|
\set -A i_alias
|
||||||
\set -A i_func
|
\set -A i_func
|
||||||
|
|
||||||
# accumulate mksh built-in aliases, in ASCIIbetical order
|
# accumulate mksh built-in aliases, in ASCIIbetical order
|
||||||
i_alias[nalias]=autoload; b_alias[nalias++]='\builtin typeset -fu'
|
i_alias[nalias]=autoload; b_alias[nalias++]='\typeset -fu'
|
||||||
i_alias[nalias]=functions; b_alias[nalias++]='\builtin typeset -f'
|
i_alias[nalias]=functions; b_alias[nalias++]='\typeset -f'
|
||||||
i_alias[nalias]=hash; b_alias[nalias++]='\builtin alias -t'
|
i_alias[nalias]=hash; b_alias[nalias++]='\builtin alias -t'
|
||||||
i_alias[nalias]=history; b_alias[nalias++]='\builtin fc -l'
|
i_alias[nalias]=history; b_alias[nalias++]='\builtin fc -l'
|
||||||
i_alias[nalias]=integer; b_alias[nalias++]='\builtin typeset -i'
|
i_alias[nalias]=integer; b_alias[nalias++]='\typeset -i'
|
||||||
i_alias[nalias]=local; b_alias[nalias++]='\builtin typeset'
|
i_alias[nalias]=local; b_alias[nalias++]='\typeset'
|
||||||
i_alias[nalias]=login; b_alias[nalias++]='\exec login'
|
i_alias[nalias]=login; b_alias[nalias++]='\exec login'
|
||||||
i_alias[nalias]=nameref; b_alias[nalias++]='\builtin typeset -n'
|
i_alias[nalias]=nameref; b_alias[nalias++]='\typeset -n'
|
||||||
i_alias[nalias]=nohup; b_alias[nalias++]='nohup '
|
i_alias[nalias]=nohup; b_alias[nalias++]='nohup '
|
||||||
i_alias[nalias]=r; b_alias[nalias++]='\builtin fc -e -'
|
i_alias[nalias]=r; b_alias[nalias++]='\builtin fc -e -'
|
||||||
i_alias[nalias]=source; b_alias[nalias++]='PATH=$PATH:. \command .'
|
i_alias[nalias]=source; b_alias[nalias++]='PATH=$PATH:. \command .'
|
||||||
|
20
lex.c
20
lex.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
* 2011, 2012, 2013, 2014
|
* 2011, 2012, 2013, 2014, 2015
|
||||||
* Thorsten Glaser <tg@mirbsd.org>
|
* Thorsten Glaser <tg@mirbsd.org>
|
||||||
*
|
*
|
||||||
* Provided that these terms and disclaimer and all copyright notices
|
* Provided that these terms and disclaimer and all copyright notices
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.196 2015/03/01 16:02:48 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.197 2015/03/14 05:23:15 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* states while lexing word
|
* states while lexing word
|
||||||
@ -1044,13 +1044,16 @@ yylex(int cf)
|
|||||||
} else
|
} else
|
||||||
while ((dp - ident) < IDENT && (c = *sp++) == CHAR)
|
while ((dp - ident) < IDENT && (c = *sp++) == CHAR)
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
/* make sure the ident array stays NUL padded */
|
|
||||||
memset(dp, 0, (ident + IDENT) - dp + 1);
|
|
||||||
if (c != EOS)
|
if (c != EOS)
|
||||||
/* word is not unquoted */
|
/* word is not unquoted */
|
||||||
*ident = '\0';
|
dp = ident;
|
||||||
|
/* make sure the ident array stays NUL padded */
|
||||||
|
memset(dp, 0, (ident + IDENT) - dp + 1);
|
||||||
|
|
||||||
if (*ident != '\0' && (cf & (KEYWORD | ALIAS))) {
|
if (!(cf & (KEYWORD | ALIAS)))
|
||||||
|
return (LWORD);
|
||||||
|
|
||||||
|
if (*ident != '\0') {
|
||||||
struct tbl *p;
|
struct tbl *p;
|
||||||
uint32_t h = hash(ident);
|
uint32_t h = hash(ident);
|
||||||
|
|
||||||
@ -1106,6 +1109,11 @@ yylex(int cf)
|
|||||||
goto Again;
|
goto Again;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (cf & ALIAS) {
|
||||||
|
/* retain typeset et al. even when quoted */
|
||||||
|
if (assign_command((dp = wdstrip(yylval.cp, 0))))
|
||||||
|
strlcpy(ident, dp, sizeof(ident));
|
||||||
|
afree(dp, ATEMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (LWORD);
|
return (LWORD);
|
||||||
|
12
main.c
12
main.c
@ -34,7 +34,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.289 2015/03/08 22:54:33 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.290 2015/03/14 05:23:15 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ static const char *initcoms[] = {
|
|||||||
Ttypeset, "-x", "HOME", "PATH", "SHELL", NULL,
|
Ttypeset, "-x", "HOME", "PATH", "SHELL", NULL,
|
||||||
Ttypeset, "-i10", "COLUMNS", "LINES", "SECONDS", "TMOUT", NULL,
|
Ttypeset, "-i10", "COLUMNS", "LINES", "SECONDS", "TMOUT", NULL,
|
||||||
Talias,
|
Talias,
|
||||||
"integer=\\builtin typeset -i",
|
"integer=\\typeset -i",
|
||||||
"local=\\builtin typeset",
|
"local=\\typeset",
|
||||||
/* not "alias -t --": hash -r needs to work */
|
/* not "alias -t --": hash -r needs to work */
|
||||||
"hash=\\builtin alias -t",
|
"hash=\\builtin alias -t",
|
||||||
"type=\\builtin whence -v",
|
"type=\\builtin whence -v",
|
||||||
@ -76,10 +76,10 @@ static const char *initcoms[] = {
|
|||||||
/* not in ARGE mksh due to no job control */
|
/* not in ARGE mksh due to no job control */
|
||||||
"stop=\\kill -STOP",
|
"stop=\\kill -STOP",
|
||||||
#endif
|
#endif
|
||||||
"autoload=\\builtin typeset -fu",
|
"autoload=\\typeset -fu",
|
||||||
"functions=\\builtin typeset -f",
|
"functions=\\typeset -f",
|
||||||
"history=\\builtin fc -l",
|
"history=\\builtin fc -l",
|
||||||
"nameref=\\builtin typeset -n",
|
"nameref=\\typeset -n",
|
||||||
"nohup=nohup ",
|
"nohup=nohup ",
|
||||||
"r=\\builtin fc -e -",
|
"r=\\builtin fc -e -",
|
||||||
"source=PATH=$PATH:. \\command .",
|
"source=PATH=$PATH:. \\command .",
|
||||||
|
12
mksh.1
12
mksh.1
@ -1,4 +1,4 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.354 2015/03/14 05:17:17 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.355 2015/03/14 05:23:16 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.157 2015/03/13 19:58:40 jmc Exp $
|
.\" $OpenBSD: ksh.1,v 1.157 2015/03/13 19:58:40 jmc Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||||
@ -1120,14 +1120,14 @@ also by newline) may be one same parse tree.
|
|||||||
.Pp
|
.Pp
|
||||||
The following command aliases are defined automatically by the shell:
|
The following command aliases are defined automatically by the shell:
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
autoload=\*(aq\ebuiltin typeset \-fu\*(aq
|
autoload=\*(aq\etypeset \-fu\*(aq
|
||||||
functions=\*(aq\ebuiltin typeset \-f\*(aq
|
functions=\*(aq\etypeset \-f\*(aq
|
||||||
hash=\*(aq\ebuiltin alias \-t\*(aq
|
hash=\*(aq\ebuiltin alias \-t\*(aq
|
||||||
history=\*(aq\ebuiltin fc \-l\*(aq
|
history=\*(aq\ebuiltin fc \-l\*(aq
|
||||||
integer=\*(aq\ebuiltin typeset \-i\*(aq
|
integer=\*(aq\etypeset \-i\*(aq
|
||||||
local=\*(aq\ebuiltin typeset\*(aq
|
local=\*(aq\etypeset\*(aq
|
||||||
login=\*(aq\eexec login\*(aq
|
login=\*(aq\eexec login\*(aq
|
||||||
nameref=\*(aq\ebuiltin typeset \-n\*(aq
|
nameref=\*(aq\etypeset \-n\*(aq
|
||||||
nohup=\*(aqnohup \*(aq
|
nohup=\*(aqnohup \*(aq
|
||||||
r=\*(aq\ebuiltin fc \-e \-\*(aq
|
r=\*(aq\ebuiltin fc \-e \-\*(aq
|
||||||
source=\*(aqPATH=$PATH:. \ecommand .'
|
source=\*(aqPATH=$PATH:. \ecommand .'
|
||||||
|
5
sh.h
5
sh.h
@ -169,9 +169,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.718 2015/03/14 04:37:54 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.719 2015/03/14 05:23:17 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R50 2015/03/08"
|
#define MKSH_VERSION "R50 2015/03/13"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
@ -1916,6 +1916,7 @@ char *shf_smprintf(const char *, ...)
|
|||||||
ssize_t shf_vfprintf(struct shf *, const char *, va_list)
|
ssize_t shf_vfprintf(struct shf *, const char *, va_list)
|
||||||
MKSH_A_FORMAT(__printf__, 2, 0);
|
MKSH_A_FORMAT(__printf__, 2, 0);
|
||||||
/* syn.c */
|
/* syn.c */
|
||||||
|
int assign_command(const char *);
|
||||||
void initkeywords(void);
|
void initkeywords(void);
|
||||||
struct op *compile(Source *, bool);
|
struct op *compile(Source *, bool);
|
||||||
bool parse_usec(const char *, struct timeval *);
|
bool parse_usec(const char *, struct timeval *);
|
||||||
|
5
syn.c
5
syn.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.98 2015/03/14 04:38:13 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.99 2015/03/14 05:23:18 tg Exp $");
|
||||||
|
|
||||||
struct nesting_state {
|
struct nesting_state {
|
||||||
int start_token; /* token than began nesting (eg, FOR) */
|
int start_token; /* token than began nesting (eg, FOR) */
|
||||||
@ -58,7 +58,6 @@ static struct op *newtp(int);
|
|||||||
static void syntaxerr(const char *) MKSH_A_NORETURN;
|
static void syntaxerr(const char *) MKSH_A_NORETURN;
|
||||||
static void nesting_push(struct nesting_state *, int);
|
static void nesting_push(struct nesting_state *, int);
|
||||||
static void nesting_pop(struct nesting_state *);
|
static void nesting_pop(struct nesting_state *);
|
||||||
static int assign_command(const char *);
|
|
||||||
static int inalias(struct source *) MKSH_A_PURE;
|
static int inalias(struct source *) MKSH_A_PURE;
|
||||||
static Test_op dbtestp_isa(Test_env *, Test_meta);
|
static Test_op dbtestp_isa(Test_env *, Test_meta);
|
||||||
static const char *dbtestp_getopnd(Test_env *, Test_op, bool);
|
static const char *dbtestp_getopnd(Test_env *, Test_op, bool);
|
||||||
@ -927,7 +926,7 @@ compile(Source *s, bool skiputf8bom)
|
|||||||
* a=a
|
* a=a
|
||||||
* $
|
* $
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
assign_command(const char *s)
|
assign_command(const char *s)
|
||||||
{
|
{
|
||||||
if (!*s)
|
if (!*s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user