Il giorno sab 14 ago 2021 alle ore 00:30 Harald van Dijk <[email protected]>
ha scritto:

>
> However, for functions defined outside of a script, the only way to
> interpret the requirements is for LINENO to remain relative to the start
> of the function as it is now.
>

 Hi Harald, thank you for having shared your point of view.

 I agree that POSIX specs are important but not mandatory.
 Moreover they not always very specific like in this case.

 Obviously for the functions defined elsewhere it might be different.
 I prepared a test but feel free to improve it. Here the results:

roberto@vm-ubuntu18:~/tinycore-editor/busybox$ src/busybox ash ./test2.sh
ash: using fallback suid method
ciao! at line 29 == 29
hello at line 22 == 22
ERROR: test2.sh failed at line 23, rc: 1
onerror() at line 16 == 16
mytest should have failed at line 23
pippo
ERROR: test2.sh failed at line 34, rc: 1
onerror() at line 16 == 16
exit at line 34 == 34 with pippo but not pluto


-- 
Roberto A. Foglietta
+39.349.33.30.697
#!/bin/ash

pwd=$(realpath $(dirname $0))

. $pwd/funcs.sh




















trap 'onerror $LINENO $FUNCNAME' ERR
trap 'echo exit at line $LINENO == 34 with pippo but not pluto' EXIT

echo "ciao! at line $LINENO == 29"
mytest
echo "mytest should have failed at line 23"
echo "pippo"
set -e
false



echo "pluto at line 38"
#!/bin/ash

function realexit() {
	trap - EXIT
	exit $1
}

function perr() {
	echo -e "\e[1;31m$@\e[0m"
}

function onerror() {
	rc=$?
#	echo
	perr "ERROR: $(basename $0) failed${2+ in $2()} at line $1, rc: $rc" 
	echo "onerror() at line $LINENO == 16"
#	echo
#	realexit $rc
}

function mytest() {
	echo "hello at line $LINENO == 22"
	false
}
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to