mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-10 04:00:34 +02:00
commit bash-20120504 snapshot
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
BUILD_DIR=/usr/local/build/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
export THIS_SH PATH
|
||||
|
||||
rm -f /tmp/xx
|
||||
|
||||
/bin/sh "$@"
|
||||
@@ -109,5 +109,6 @@ shopt -q -o history
|
||||
echo $?
|
||||
|
||||
${THIS_SH} ./history1.sub
|
||||
rm foohist-*
|
||||
|
||||
${THIS_SH} ./history2.sub
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
trap 'rm /tmp/newhistory' 0
|
||||
|
||||
# bad options
|
||||
history -x
|
||||
# cannot use -r and -w at the same time
|
||||
history -r -w /dev/null
|
||||
|
||||
# bad option
|
||||
fc -v
|
||||
|
||||
unset HISTFILESIZE
|
||||
|
||||
# all of these should result in an empty history list
|
||||
history -c
|
||||
history -r /dev/null
|
||||
history -n /dev/null
|
||||
history -c
|
||||
|
||||
HISTFILE=history.list
|
||||
HISTCONTROL=ignoreboth
|
||||
HISTIGNORE='&:history*:fc*'
|
||||
HISTSIZE=32
|
||||
|
||||
shopt -s cmdhist
|
||||
set -o history
|
||||
|
||||
history
|
||||
|
||||
fc -l
|
||||
fc -nl
|
||||
|
||||
fc -lr
|
||||
fc -nlr
|
||||
|
||||
history -s "echo line for history"
|
||||
history
|
||||
|
||||
history -p '!!'
|
||||
|
||||
fc -nl
|
||||
|
||||
HISTFILE=/tmp/newhistory
|
||||
history -a
|
||||
echo displaying \$HISTFILE after history -a
|
||||
cat $HISTFILE
|
||||
|
||||
history
|
||||
history -w
|
||||
cat $HISTFILE
|
||||
|
||||
history -s "echo line 2 for history"
|
||||
history
|
||||
history -p '!e'
|
||||
history -p '!!'
|
||||
|
||||
# this should show up as one history entry
|
||||
for x in one two three
|
||||
do
|
||||
:
|
||||
done
|
||||
history
|
||||
|
||||
# just a basic test. a full test suite for history expansion should be
|
||||
# created
|
||||
set -H
|
||||
!!
|
||||
!e
|
||||
|
||||
unset HISTSIZE
|
||||
unset HISTFILE
|
||||
|
||||
fc -l 4
|
||||
fc -l 4 8
|
||||
|
||||
fc -l one=two three=four 502
|
||||
|
||||
history 4
|
||||
|
||||
shopt -so history
|
||||
shopt -s expand_aliases
|
||||
|
||||
alias r="fc -s"
|
||||
|
||||
echo aa ab ac
|
||||
|
||||
r a=x
|
||||
r x=4 b=8
|
||||
|
||||
# this had better fail with `no command found'
|
||||
r cc
|
||||
|
||||
unalias -a
|
||||
alias
|
||||
|
||||
# these two blocks had better both result in the same output
|
||||
echo aa
|
||||
echo bb
|
||||
echo cc
|
||||
fc -e cat
|
||||
|
||||
echo aa
|
||||
echo bb
|
||||
echo cc
|
||||
fc -e cat -1
|
||||
|
||||
set +o history
|
||||
|
||||
shopt -q -o history
|
||||
echo $?
|
||||
|
||||
${THIS_SH} ./history1.sub
|
||||
|
||||
${THIS_SH} ./history2.sub
|
||||
@@ -1,3 +1,5 @@
|
||||
trap 'rm -f $HISTFILE' 0 1 2 3 6 15
|
||||
|
||||
HISTFILE=foohist-$$
|
||||
unset HISTIGNORE HISTCONTROL
|
||||
set -o history
|
||||
|
||||
@@ -59,3 +59,34 @@ argv[1] = <aaa^?bbb>
|
||||
argv[1] = <ccc^?ddd>
|
||||
argv[1] = <eee^?fff>
|
||||
argv[1] = <ggg^?hhh>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <x^?y>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <^?>
|
||||
argv[1] = <^? >
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?x>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?>
|
||||
argv[1] = < ^?x>
|
||||
argv[1] = <^?x>
|
||||
argv[1] = <^?>
|
||||
argv[1] = < ^? x>
|
||||
argv[1] = <^? x>
|
||||
argv[1] = <^? >
|
||||
|
||||
@@ -141,3 +141,5 @@ recho aaa$'\177'bbb
|
||||
recho ccc""ddd
|
||||
recho "eeefff"
|
||||
recho ggg"$(echo $'\177')"hhh
|
||||
|
||||
${THIS_SH} ./iquote1.sub
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
# bug in bash up to and including bash-3.0 (including patches)
|
||||
#
|
||||
# problem is conflict between CTLNUL used internally to denote quoted null
|
||||
# characters and its value (0x7f) appearing in the expansion of a variable
|
||||
#
|
||||
unset x
|
||||
recho "xxx${x}yyy"
|
||||
|
||||
y=$'\177'
|
||||
recho "xxx${y}yyy"
|
||||
|
||||
unset y
|
||||
|
||||
unset undef
|
||||
|
||||
set ""
|
||||
recho ${undef-"x$*y"}
|
||||
|
||||
set $'\177'
|
||||
recho ${undef-"x$*y"}
|
||||
|
||||
shift $#
|
||||
|
||||
f()
|
||||
{
|
||||
recho "-${*-x}-"
|
||||
}
|
||||
|
||||
f ''
|
||||
f $'\177'
|
||||
|
||||
unset -f f
|
||||
|
||||
x=12345
|
||||
|
||||
recho "${x:6:1}"
|
||||
|
||||
x=
|
||||
recho "${x:0:1}"
|
||||
|
||||
y=$'\177'
|
||||
recho "${y:0:1}"
|
||||
|
||||
y=xxx$'\177'yyy
|
||||
recho "${y:3:3}"
|
||||
|
||||
unset x y
|
||||
|
||||
eval tmp=`printf "$'\\\\\x%x'\n" 127`
|
||||
printf "%#1x\n" "'$tmp"
|
||||
|
||||
x=$'\177'
|
||||
printf "%#1x\n" "'$x"
|
||||
|
||||
a=127
|
||||
eval c=\$\'\\$(printf '%o' $a)\'
|
||||
printf "%#1x\n" "'$c"
|
||||
|
||||
recho "$c"
|
||||
recho "$c"@
|
||||
recho @"$c"@
|
||||
recho @"$c"
|
||||
|
||||
recho "$c"
|
||||
recho "$c@"
|
||||
recho "@$c@"
|
||||
recho "@$c"
|
||||
|
||||
unset tmp x a c
|
||||
|
||||
qtest()
|
||||
{
|
||||
recho ${#q} "${q}" ${q}
|
||||
}
|
||||
|
||||
q=$'\x7f'
|
||||
qtest
|
||||
|
||||
q=${q}a
|
||||
qtest
|
||||
|
||||
q=$'\x7fa'
|
||||
qtest
|
||||
|
||||
q="${q}a"
|
||||
qtest
|
||||
|
||||
unset -f qtest
|
||||
unset q
|
||||
|
||||
set -- ''
|
||||
recho "${*:1}"
|
||||
recho ${*:1}
|
||||
recho -${*:1}-
|
||||
recho -"${*:1}"-
|
||||
|
||||
set $'\177'
|
||||
recho "${*:1}"
|
||||
recho "-${*:1}-"
|
||||
|
||||
recho ${*:1}
|
||||
recho -${*:1}-
|
||||
|
||||
shift $#
|
||||
|
||||
DEL=`awk 'END{printf("%c", 0+127)}' </dev/null`
|
||||
T1=a\ $DEL
|
||||
T2="a $DEL"
|
||||
set -- x $(echo $T1|wc -c) $(echo $T2|wc -c); shift
|
||||
L1=$1; L2=$2
|
||||
case "$L1/$L2" in
|
||||
4/4) echo ok;;
|
||||
*) echo CTLNUL bug: L1=$L1, L2=$L2;;
|
||||
esac
|
||||
|
||||
x=$'\177'
|
||||
recho "aaa${x}bbb"
|
||||
recho ccc"${x}"ddd
|
||||
recho eee"$x"fff
|
||||
recho ggg"$(echo $x)"hhh
|
||||
|
||||
x=
|
||||
recho "aaa${x}bbb"
|
||||
recho ccc"${x}"ddd
|
||||
recho eee"$x"fff
|
||||
recho ggg"$(echo $x)"hhh
|
||||
|
||||
set -- $'\177'
|
||||
recho "aaa${1}bbb"
|
||||
recho ccc"${1}"ddd
|
||||
recho eee"$1"fff
|
||||
recho ggg"$(echo $1)"hhh
|
||||
|
||||
set -- ""
|
||||
recho "aaa${1}bbb"
|
||||
recho ccc"${1}"ddd
|
||||
recho eee"$1"fff
|
||||
recho ggg"$(echo $1)"hhh
|
||||
|
||||
recho aaa$'\177'bbb
|
||||
recho ccc""ddd
|
||||
recho "eeefff"
|
||||
recho ggg"$(echo $'\177')"hhh
|
||||
@@ -0,0 +1,43 @@
|
||||
# Problems with variables that expand to 0x7f and quoted nulls in the same
|
||||
# expansion -- affects bash versions 4.0-post 4.2
|
||||
a=x
|
||||
b=
|
||||
del=$'\x7f'
|
||||
|
||||
set ""
|
||||
|
||||
recho ${undef-"x$*y"}
|
||||
recho "x$*y"
|
||||
recho x"$*"y
|
||||
recho x"$del"y
|
||||
|
||||
recho ${undef-"$@"}
|
||||
recho "$@"
|
||||
recho "${@}"
|
||||
recho ${undef-"$*"}
|
||||
recho "$*"
|
||||
recho "${*}"
|
||||
|
||||
recho "$del${a#x}"
|
||||
recho "$del ${a#x}"
|
||||
recho " $del${a#x}"
|
||||
|
||||
recho " $del$b"
|
||||
recho " $del${b}"
|
||||
recho " $del${b#x}"
|
||||
recho " $del${a#x}"
|
||||
|
||||
recho " $del${a%x}"
|
||||
recho " $del${a:0:0}"
|
||||
recho " $del"${a:0:0}
|
||||
recho " $del""${a:0:0}"
|
||||
recho " $del${a}"
|
||||
recho " $del"
|
||||
recho " ${del}${a:0:0}"
|
||||
recho " ${del:0:1}${a:0:0}"
|
||||
recho " ${del:0:1}${a}"
|
||||
recho "${del:0:1}${a#d}"
|
||||
recho "${del:0:1}${a#x}"
|
||||
recho " ${del:0:1} ${a}"
|
||||
recho "${del:0:1} ${a#d}"
|
||||
recho "${del:0:1} ${a#x}"
|
||||
@@ -0,0 +1,50 @@
|
||||
:; ./shx
|
||||
|
||||
sh:
|
||||
<&$fd ok
|
||||
nlbq Mon Aug 3 02:45:00 EDT 1992
|
||||
bang geoff
|
||||
quote 712824302
|
||||
setbq defmsgid=<1992Aug3.024502.6176@host>
|
||||
bgwait sleep done... wait 6187
|
||||
|
||||
|
||||
bash:
|
||||
<&$fd ok
|
||||
nlbq Mon Aug 3 02:45:09 EDT 1992
|
||||
bang geoff
|
||||
quote 712824311
|
||||
setbq defmsgid=<1992Aug3.024512.6212@host>
|
||||
bgwait sleep done... wait 6223
|
||||
|
||||
|
||||
ash:
|
||||
<&$fd shx1: 4: Syntax error: Bad fd number
|
||||
nlbq Mon Aug 3 02:45:19 EDT 1992
|
||||
bang geoff
|
||||
quote getdate: `"now"' not a valid date
|
||||
|
||||
setbq defmsgid=<1992Aug3.` echo 024521
|
||||
bgwait sleep done... wait 6241
|
||||
|
||||
|
||||
ksh:
|
||||
<&$fd ok
|
||||
nlbq ./shx: 6248 Memory fault - core dumped
|
||||
bang geoff
|
||||
quote getdate: `"now"' not a valid date
|
||||
|
||||
setbq defmsgid=<1992Aug3.024530.6257@host>
|
||||
bgwait no such job: 6265
|
||||
wait 6265
|
||||
sleep done...
|
||||
|
||||
zsh:
|
||||
<&$fd ok
|
||||
nlbq Mon Aug 3 02:45:36 EDT 1992
|
||||
bang shx3: event not found: /s/ [4]
|
||||
quote 712824337
|
||||
setbq defmsgid=<..6290@host>
|
||||
bgwait shx7: unmatched " [9]
|
||||
sleep done...
|
||||
:;
|
||||
@@ -0,0 +1,10 @@
|
||||
#! /bin/sh
|
||||
for cmd in sh bash ash ksh zsh
|
||||
do
|
||||
echo
|
||||
echo $cmd:
|
||||
for demo in shx?
|
||||
do
|
||||
$cmd $demo
|
||||
done
|
||||
done
|
||||
@@ -0,0 +1,61 @@
|
||||
LC_ALL=C
|
||||
LANG=C
|
||||
|
||||
SHELLSTART=$(date +%s)
|
||||
SECS=1275250155
|
||||
export TZ=EST5EDT
|
||||
|
||||
case $SHELLSTART in
|
||||
*s*) SHELLSTART=$(perl -e 'print time') ;; # take a shot
|
||||
esac
|
||||
|
||||
printf "%()T\n" $SECS
|
||||
printf "%(abde)Z\n" -1
|
||||
|
||||
printf "%(%e-%b-%Y %T)T\n" $SECS
|
||||
|
||||
printf -v v1 "%(%e-%b-%Y %T)T\n" $(date +%s)
|
||||
printf -v v2 "%(%e-%b-%Y %T)T\n" -1
|
||||
|
||||
case $v1 in
|
||||
$v2) ;;
|
||||
*) echo "current time and -1 possible mismatch|$v1|$v2|" >&2 ;;
|
||||
esac
|
||||
unset v1 v2
|
||||
|
||||
v1=$(date +%s)
|
||||
printf -v v2 "%(%s)T" -1
|
||||
|
||||
case $v1 in
|
||||
$v2) ;;
|
||||
*) echo "current time mismatch:$v1|$v2|" >&2 ;;
|
||||
esac
|
||||
unset v1 v2
|
||||
|
||||
printf "%(%x %X)T\n" $(( $SECS - 3600 ))
|
||||
|
||||
printf -v v1 "%(%F %r)T\n" $SHELLSTART
|
||||
printf -v v2 "%(%F %r)T\n" -2
|
||||
|
||||
case $v1 in
|
||||
$v2) ;;
|
||||
*) echo "shell start time and -2 possible mismatch|$v1|$v2|" >&2 ;;
|
||||
esac
|
||||
unset v1 v2
|
||||
|
||||
printf "current time: %(%F %r)T\n" $SECS
|
||||
|
||||
printf "epoch time: %(%F %r %z)T\n" 0
|
||||
printf "random time: %(%F %r %z)T\n" $SECS
|
||||
|
||||
printf "local time: %(%a %b %e %H:%M:%S %Z %Y)T\n" $SECS
|
||||
|
||||
# test fieldwidth, justification, precision
|
||||
printf "%-40.50(%a %b %e %H:%M:%S %Z %Y)T date-style time\n" $SECS
|
||||
|
||||
# test fieldwidth, justification, precision, embedded parens
|
||||
printf "%-40.50(%x (foo) %X)T date-style time\n" $SECS
|
||||
|
||||
# problem introduced in bash-4.2 patch 5
|
||||
unset TZ
|
||||
printf '%(%Y-%m-%d %H:%M:%S %Z)T\n' >/dev/null
|
||||
Reference in New Issue
Block a user