mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-07-12 17:11:25 +02:00
This addresses the issue that "typeset foo" creates $foo set to an empty string, which differs from typeset handling in bash and ksh. It does this by concealing the internal value rather than alter the way internal values are defaulted. This imposes the following changes: A typeset variable with no assignment triggers NO_UNSET warnings when the name is used in parameter expansion or math. The typeset -AEFHLRTZailux options are applied upon the first assignment to the variable. Explicit unset before the first assignment discards all of those properties. If any option is applied to an existing name, historic behavior is unchanged. Consequent to the foregoing, the (t) parameter expansion flag prints nothing until after the first assignment, and the (i) and (I) subscript flags also print nothing. The bash behavior of "unset foo; typeset -p foo" is NOT used. This is called out as an emulation distinction, not a change. The test cases have not been updated, so several now fail. The test harness has been updated to declare default values.
27 lines
764 B
Bash
27 lines
764 B
Bash
#!/bin/zsh -f
|
|
|
|
emulate zsh
|
|
|
|
# Run all specified tests, keeping count of which succeeded.
|
|
# The reason for this extra layer above the test script is to
|
|
# protect from catastrophic failure of an individual test.
|
|
# We could probably do that with subshells instead.
|
|
|
|
integer success=0 failure=0 skipped=0 retval
|
|
for file in "${(f)ZTST_testlist}"; do
|
|
$ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh $file
|
|
retval=$?
|
|
if (( $retval == 2 )); then
|
|
(( skipped++ ))
|
|
elif (( $retval )); then
|
|
(( failure++ ))
|
|
else
|
|
(( success++ ))
|
|
fi
|
|
done
|
|
print "**************************************
|
|
$success successful test script${${success:#1}:+s}, \
|
|
$failure failure${${failure:#1}:+s}, \
|
|
$skipped skipped
|
|
**************************************"
|
|
return $(( failure ? 1 : 0 ))
|