17 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
1
answer
90
views
Printf command stops working when DEBUG trap is active?
When I set a DEBUG trap in Bash like this:
set -o functrace
trap 'echo "# $BASH_COMMAND" >&2' DEBUG
Suddenly, this function stopped working:
getBase() {
local base="1ドル"
...
4
votes
1
answer
100
views
How to check if trap is ignored?
Subshell traps show parent traps with trap -p, but do not execute them.
Is it possible to get the "do not execute them" state? when trap -p returns the parent state? Do I have to track trap ...
0
votes
1
answer
60
views
The subshell's trap is caught by the main shell, but the -E option is not used
function set_trap_for_exception() {
function _on_error() {
echo "error start"
exit 1
}
trap '_on_error "$BASH_COMMAND" $LINENO' ERR
}
function is_hygon_cpu() {
...
0
votes
1
answer
66
views
How to logically handle arithmetic expressions when using ERR trap?
I came across something funny today:
#!/bin/bash
trap 'echo>&2 "~ trapped on $? ~"' ERR
declare -i i=0
while ((i < 10)); do
printf "%d " $i
((i++))
done
echo
...
0
votes
2
answers
75
views
Best way to generically "suspend" a trap handler - unset and reassign it later?
I need to "deactivate" one trap handler temporarily and reinstate it later (to whatever it was before).
What is the best way to do this?
3
votes
2
answers
130
views
How to best avoid trap handlers interaction when using set -E -T?
I had the following snippet:
#!/bin/bash
set -E -T
export ERR_FLAG=0
err_trap() {
echo "hit err_trap - setting ERR_FLAG"
ERR_FLAG=1
}
return_trap() {
echo "...
3
votes
2
answers
132
views
trap ERR - get only the deepest function trace
The following (with set -E):
1 #!/bin/bash
2
3 set -E
4
5 trap 'trap_err' ERR
6
7 trap_err() {
8 echo "D: $BASH_COMMAND . ${FUNCNAME[@]:1} . ...
0
votes
1
answer
187
views
Difference of 'software interrupt' and 'exception' in RISC-V
I'm reading privileged ISA manual of RISC-V, and I found that they strictly separate the 'interrupt' and 'exception' and 'trap'. In my understanding, the asynchronous event from outside is 'interrupt',...
1
vote
0
answers
101
views
Zabbix 6.4 interface traps down/up clearing trigger doesnt work
I am new to Zabbix and at the moment losing my mind how to setup trigger for receiving snmp traps interface up /down to work properly.
both snmptraps, interface down and up, I am receiving but ...
1
vote
1
answer
484
views
Capture error message when trapping error in zsh script
I have a zsh script that rarely crashes with no errors showing in the log. Normally error messages appear. I'm working on a small test script and learning about trapping.
I want to print variable ...
0
votes
0
answers
21
views
String not converting to numeric [duplicate]
Hi i have strings i want to convert to numeric, basically to get the difference in area under the graph. (I have nothing to add but I have to because StackOverflow says so)
Graph looks something like ...
0
votes
1
answer
342
views
What exactly is a trap?
From what I understand, there are software interrupts and hardware interrupts. Software interrupts include exception and trap, where a trap is called explicitly (such as in the case of systemcalls) ...
0
votes
1
answer
183
views
Does the xv6 kernel pagetable have the mapping of trapframe page by default?
I am learning the trap mechanism in xv6, getting confused when I enter the kernel and see some code like p->trapframe->epc = r_sepc().
I am wondering when do the kernel put this trapframe ...
2
votes
1
answer
438
views
Using an image as orbit trap for coloring a Julia set
Searching the web I couldn't find any example on how to use a bitmap (a raster image) as orbit trap to color a Julia set or Mandelbrot set.
Here Inigo Quilez is explaining the method he uses in only ...
1
vote
1
answer
88
views
Trouble Executing Code Inside a PowerShell 'Trap' Block
I have a function that runs, and within this function, I've implemented a trap. However, it doesn't execute the code inside the trap. Instead, it writes an error message as expected, but it doesn't ...