Tiny Core Linux
Tiny Core Base => TCB Talk => Topic started by: Roberto A. Foglietta on August 13, 2021, 06:14:21 AM
-
Hi all,
this patch add the trap ERR to busybox ash. I tested it against various cases.
roberto@vm-ubuntu18:~/tinycore-editor/busybox/src$ ./busybox ash -x
ash: using fallback suid method
~/tinycore-editor/busybox/src $ trap "echo myerror; false" ERR; trap; false
+ trap 'echo myerror; false' ERR
+ trap
trap -- 'echo myerror; false' ERR
+ false
+ echo myerror
myerror
+ false
~/tinycore-editor/busybox/src $ trap -- ERR; false
+ trap -- ERR
+ false
~/tinycore-editor/busybox/src $ trap "echo myexit; false" EXIT; trap "echo myerror; false" ERR; exit 1
+ trap 'echo myexit; false' EXIT
+ trap 'echo myerror; false' ERR
+ exit 1
+ echo myexit
myexit
+ false
+ echo myerror
myerror
+ false
-
This second patch goes after the first one:
- add a bugfix to the first patch
- enable global $LINENO
At the moment when $LINENO is printed by a function the number displayed is the lines from the start of the function.
Unfortunately, this information is useless because we do not have $FUNCNAME.
Even if we have $FUNCNAME having always an absolute $LINENO will be more easier.
In fact this will be the quickest way to reach the break point
- vi script.sh :$n
The two patches goes together because having the $LINENO without the ability to use in an error trap is not very useful.
I will add in attachment a script for testing in the next post.
Please let me know what you think,
-R
-
I will add in attachment a script for testing in the next post.
-
This third patch add the support for set -E (error trace)
Please, rename the others 1of3 and 2of3. Thank you
In attachment the scripts for testing, in a tarball.
-
This 4th patch add the support for $FUNCNAME
Please, rename the others Nof4. Thank you
In attachment the scripts for testing, in a tarball.
-
This 5th patch fixes a corner-case LINENO bug
Please, rename the others Nof5. Thank you
In attachment the scripts for testing, in a tarball.
-
This 6th patch fixes FUNCNAME when no function is defined
Please, rename the others Nof6. Thank you
In attachment the scripts for testing, in a tarball.
-
This 7th patch fixes three main issues
Please, rename the others Nof7. Thank you
In attachment the scripts for testing, in a tarball.
-
This 8th patch cover another case of string evaluation
Please, rename the others Nof8. Thank you
In attachment the scripts for testing, in a tarball.
-
This 9th patch fixes some corner case related to command line execution
Please, rename the others Nof9. Thank you
-
This 10th patch is very important: rework the trap ERR because the previous was misimplemented.
Now the behaviour of trap ERR in busybox ash is compliant with the one shown by bash.
Updated test suite attached also. Please rename 0N of 10, thank you.
-
The patchset has been united in a single patch with its testsuite.
This patch add to busybox ash the following features:
- trap ERR and set -E added
- global FUNCNAME added
- LINENO became global
Future improvement could be downloaded from here
https://github.com/robang74/tinycore-editor/tree/main/busybox
Enjoy it, -R