1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

shtests: report correct line numbers for shcomp fails (re: bd38c804)

Inserting the _common script instead of sourcing it caused all test
failures in shcomp runs to be reported with the number of lines in
_common added.

src/cmd/ksh93/shtests:
- Only incorporate the aliases from _common; dot/source the rest of
  the code as normal. Replace the first few lines with the aliases
  to avoid affecting $LINENO; they are comments anyway.
This commit is contained in:
Martijn Dekker 2021-12-20 02:26:14 +00:00
parent a381a1b049
commit d3f553ca76

View file

@ -8,7 +8,7 @@ valgrindflags='--xml=yes --log-file=/dev/null --track-origins=yes --read-var-inf
USAGE=$'
[-s8?
@(#)$Id: shtests (ksh 93u+m) 2021-12-16 $
@(#)$Id: shtests (ksh 93u+m) 2021-12-20 $
]
[-author?David Korn <dgk@research.att.com>]
[-author?Glenn Fowler <gsf@research.att.com>]
@ -408,11 +408,10 @@ do [[ $i == *.sh ]] || i+='.sh'
echo test $o begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"}
tmp_s=$tmp/$u.shcomp
mkdir -m700 "$tmp_s" || exit
# must incorporate _common in script itself so the aliases are expanded at compile time
sed '/^\. .*\/_common/ {
r _common
d
}' < $i > $c.orig
# Must define aliases from _common in script itself so they are expanded at compile time.
# Replace the first few lines with those to avoid affecting $LINENO; they are comments anyway.
num_alias=$(grep -c '^alias [[:alnum:]_]\{2,\}=' _common)
{ grep '^alias [[:alnum:]_]\{2,\}=' _common; sed "1,$num_alias d" "$i"; } >$c.orig
cd "$tmp_s" || exit
if "$SHCOMP" "$c.orig" > $c
then if tmp=$tmp_s $valgrind $SHELL $trace $c