finally, all bugs fixed, adjust dot.mkshrc to use the subst code
This commit is contained in:
6
check.t
6
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.155 2008/03/01 21:10:25 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.156 2008/03/01 21:24:58 tg Rel $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -998,7 +998,9 @@ name: eglob-substrpl-1
|
|||||||
description:
|
description:
|
||||||
Check eglobbing works in substs... and they work at all
|
Check eglobbing works in substs... and they work at all
|
||||||
stdin:
|
stdin:
|
||||||
|
[[ -n $BASH_VERSION ]] && shopt -s extglob
|
||||||
x=1222321_ab/cde_b/c_1221
|
x=1222321_ab/cde_b/c_1221
|
||||||
|
y=xyz
|
||||||
echo 1: ${x/2}
|
echo 1: ${x/2}
|
||||||
echo 2: ${x//2}
|
echo 2: ${x//2}
|
||||||
echo 3: ${x/+(2)}
|
echo 3: ${x/+(2)}
|
||||||
@ -1027,6 +1029,7 @@ stdin:
|
|||||||
echo 26: ${x//\\%1/9}
|
echo 26: ${x//\\%1/9}
|
||||||
echo 27: ${x//\a/9}
|
echo 27: ${x//\a/9}
|
||||||
echo 28: ${x//\\a/9}
|
echo 28: ${x//\\a/9}
|
||||||
|
echo 29: ${x/2/$y}
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
1: 122321_ab/cde_b/c_1221
|
1: 122321_ab/cde_b/c_1221
|
||||||
2: 131_ab/cde_b/c_11
|
2: 131_ab/cde_b/c_11
|
||||||
@ -1056,6 +1059,7 @@ expected-stdout:
|
|||||||
26: 1222321_ab/cde_b/c_1221
|
26: 1222321_ab/cde_b/c_1221
|
||||||
27: 1222321_9b/cde_b/c_1221
|
27: 1222321_9b/cde_b/c_1221
|
||||||
28: 1222321_9b/cde_b/c_1221
|
28: 1222321_9b/cde_b/c_1221
|
||||||
|
29: 1xyz22321_ab/cde_b/c_1221
|
||||||
---
|
---
|
||||||
name: eglob-substrpl-2
|
name: eglob-substrpl-2
|
||||||
description:
|
description:
|
||||||
|
14
dot.mkshrc
14
dot.mkshrc
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.27 2008/03/01 16:35:30 tg Exp $
|
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.28 2008/03/01 21:24:58 tg Rel $
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2007, 2008
|
# Copyright (c) 2007, 2008
|
||||||
# Thorsten “mirabilos” Glaser <tg@mirbsd.de>
|
# Thorsten “mirabilos” Glaser <tg@mirbsd.de>
|
||||||
@ -36,7 +36,7 @@ function precmd {
|
|||||||
PS1='$(precmd)${USER:=$(ulimit -c 0;id -un 2>&- || print \?)}@${HOSTNAME%%.*}:$(
|
PS1='$(precmd)${USER:=$(ulimit -c 0;id -un 2>&- || print \?)}@${HOSTNAME%%.*}:$(
|
||||||
typeset pfx=~ wd=${PWD:-?}
|
typeset pfx=~ wd=${PWD:-?}
|
||||||
typeset -Ui n=${COLUMNS:-80}/3; (( n = n < 7 ? 7 : n ))
|
typeset -Ui n=${COLUMNS:-80}/3; (( n = n < 7 ? 7 : n ))
|
||||||
[[ ${wd#$pfx} = $wd || $pfx = ?(/) ]] || wd=\~${wd#$pfx}
|
wd=${wd/#$pfx/~}
|
||||||
pfx=; while (( (${#pfx} + ${#wd}) > n )); do
|
pfx=; while (( (${#pfx} + ${#wd}) > n )); do
|
||||||
if [[ $wd = */* ]]; then
|
if [[ $wd = */* ]]; then
|
||||||
pfx=.../
|
pfx=.../
|
||||||
@ -68,8 +68,7 @@ typeset -r DIRSTACKBASE
|
|||||||
set -A DIRSTACK
|
set -A DIRSTACK
|
||||||
function chpwd {
|
function chpwd {
|
||||||
DIRSTACK[0]=$(readlink -nf . 2>&- || print -r -- "$PWD")
|
DIRSTACK[0]=$(readlink -nf . 2>&- || print -r -- "$PWD")
|
||||||
[[ ${DIRSTACK[0]#$DIRSTACKBASE} = ${DIRSTACK[0]} ]] || \
|
DIRSTACK[0]=${DIRSTACK[0]/#$DIRSTACKBASE/~}
|
||||||
DIRSTACK[0]=\~${DIRSTACK[0]#$DIRSTACKBASE}
|
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
chpwd .
|
chpwd .
|
||||||
@ -78,9 +77,8 @@ function cd {
|
|||||||
chpwd "$@"
|
chpwd "$@"
|
||||||
}
|
}
|
||||||
function cd_csh {
|
function cd_csh {
|
||||||
typeset d t=$1
|
typeset d t=${1/#~/$DIRSTACKBASE}
|
||||||
|
|
||||||
[[ $t = ~* ]] && t=$DIRSTACKBASE${t#~}
|
|
||||||
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 - }."
|
||||||
return 1
|
return 1
|
||||||
@ -111,7 +109,7 @@ function dirs {
|
|||||||
fv=0
|
fv=0
|
||||||
while (( fv < ${#DIRSTACK[*]} )); do
|
while (( fv < ${#DIRSTACK[*]} )); do
|
||||||
d=${DIRSTACK[fv]}
|
d=${DIRSTACK[fv]}
|
||||||
[[ $fl$d = 1~* ]] && d=$DIRSTACKBASE${d#~}
|
(( fl )) && d=${d/#~/$DIRSTACKBASE}
|
||||||
print -r -- "$fv $d"
|
print -r -- "$fv $d"
|
||||||
let fv++
|
let fv++
|
||||||
done
|
done
|
||||||
@ -119,7 +117,7 @@ function dirs {
|
|||||||
fv=0
|
fv=0
|
||||||
while (( fv < ${#DIRSTACK[*]} )); do
|
while (( fv < ${#DIRSTACK[*]} )); do
|
||||||
d=${DIRSTACK[fv]}
|
d=${DIRSTACK[fv]}
|
||||||
[[ $fl$d = 1~* ]] && d=$DIRSTACKBASE${d#~}
|
(( fl )) && d=${d/#~/$DIRSTACKBASE}
|
||||||
if (( fn && (cpos+=${#d}+1) >= 79 && ${#d} < 80 )); then
|
if (( fn && (cpos+=${#d}+1) >= 79 && ${#d} < 80 )); then
|
||||||
print
|
print
|
||||||
(( cpos = ${#d} + 1 ))
|
(( cpos = ${#d} + 1 ))
|
||||||
|
9
eval.c
9
eval.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.43 2008/03/01 21:10:25 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.44 2008/03/01 21:24:58 tg Exp $");
|
||||||
|
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
#define MKSH_NOPWNAM
|
#define MKSH_NOPWNAM
|
||||||
@ -393,7 +393,12 @@ expand(const char *cp, /* input word */
|
|||||||
sp += (d ? d : p) - s - 1;
|
sp += (d ? d : p) - s - 1;
|
||||||
tpat0 = wdstrip(s, true, true);
|
tpat0 = wdstrip(s, true, true);
|
||||||
pat = substitute(tpat0, 0);
|
pat = substitute(tpat0, 0);
|
||||||
rrep = d ? wdstrip(p, true, false) : null;
|
if (d) {
|
||||||
|
d = wdstrip(p, true, false);
|
||||||
|
rrep = substitute(d, 0);
|
||||||
|
afree(d, ATEMP);
|
||||||
|
} else
|
||||||
|
rrep = null;
|
||||||
afree(s, ATEMP);
|
afree(s, ATEMP);
|
||||||
s = d = pat;
|
s = d = pat;
|
||||||
while (*s)
|
while (*s)
|
||||||
|
Reference in New Issue
Block a user