commit bash-20120420 snapshot

This commit is contained in:
Chet Ramey
2012-05-02 08:28:58 -04:00
parent 63817e33cd
commit e107650cbf
22 changed files with 14389 additions and 55 deletions
+12
View File
@@ -0,0 +1,12 @@
cat <<!
one
two
three
!
history
cat <<!
one
two
three
!
Binary file not shown.
Binary file not shown.
+3
View File
@@ -314,3 +314,6 @@ ${THIS_SH} ./printf1.sub
${THIS_SH} ./printf2.sub
${THIS_SH} ./printf3.sub
${THIS_SH} ./printf4.sub
+6 -1
View File
@@ -5,12 +5,17 @@ SHELLSTART=$(date +%s)
SECS=1275250155
export TZ=EST5EDT
case $SHELLSTART in
*s*) SHELLSTART=$(perl -e 'print time') ; DATESECS=false ;; # take a shot
*) DATESECS=true ;;
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 v1 "%(%e-%b-%Y %T)T\n" $( $DATESECS && date +%s || perl -e 'print time')
printf -v v2 "%(%e-%b-%Y %T)T\n" -1
case $v1 in
+61
View File
@@ -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
+69
View File
@@ -0,0 +1,69 @@
# Problems with padding, field widths, and `+' through bash-4.2
printf "x%10.0fx\n" 123
printf -v foo "x%10.0fx" 123
echo "$foo"
printf "x%10.0fx\n" 123
printf -v foo "x%10.0fx" 123
echo "$foo"
printf "x%10.fx\n" 123
printf -v foo "x%10.fx" 123
echo "$foo"
printf "x%10.2fx\n" 123
printf -v foo "x%10.2fx" 123
echo "$foo"
printf "x%10.02fx\n" 123
printf -v foo "x%10.02fx" 123
echo "$foo"
printf "x%-010.0fx\n" 123
printf -v foo "x%-010.0fx" 123
echo "$foo"
printf "x%+010.0ex\n" 123
printf -v foo "x%+010.0ex" 123
echo "$foo"
printf "x%+010.0fx\n" 123
printf -v foo "x%+010.0fx" 123
echo "$foo"
printf "x%+010.0gx\n" 123
printf -v foo "x%+010.0gx" 123
echo "$foo"
printf "x%+010.0dx\n" 123
printf -v foo "x%+010.0dx" 123
echo "$foo"
printf "x%+010.0ldx\n" 123
printf -v foo "x%+010.0ldx" 123
echo "$foo"
printf "x%+010.0xx\n" 123
printf -v foo "x%+010.0xx" 123
echo "$foo"
printf "x%-+10.0fx\n" 123
printf -v foo "x%-+10.0fx" 123
echo "$foo"
printf "x%-+10.0dx\n" 123
printf -v foo "x%-+10.0dx" 123
echo "$foo"
printf "%f\n" -123
printf -v foo "%f" -123
echo "$foo"
printf "x%+10.0fx\n" 123
printf -v foo "x%+10.0fx" 123
echo "$foo"
printf "x%+10.0dx\n" 123
printf -v foo "x%+10.0dx" 123
echo "$foo"
+5 -3
View File
@@ -1,5 +1,7 @@
# See whether or not we can use `diff -a'
( diff -a ./printf.tests ./printf.tests >/dev/null 2>&1 ) && AFLAG=-a
#( diff -a ./printf.tests ./printf.tests >/dev/null 2>&1 ) && AFLAG=-a
${THIS_SH} ./printf.tests > /tmp/xx 2>&1
diff $AFLAG /tmp/xx printf.right && rm -f /tmp/xx
# use cat -v (and assume it's there) to make control chars visible
${THIS_SH} ./printf.tests 2>&1 | cat -v > /tmp/xx
#diff $AFLAG /tmp/xx printf.right && rm -f /tmp/xx
diff /tmp/xx printf.right && rm -f /tmp/xx