Questions tagged [error-handling]
Use this tag for questions on how to handle errors generated in shell scripts.
343 questions
2 votes
1 answer
155 views
Bash exception handling with a stack trace and cleanup code - how to implement?
When using the set -e flag in Bash, then it's difficult to get user-friendly error messages (a stack trace) and it's difficult to add cleanup code that executes before your script exits with an error ...
1 vote
0 answers
77 views
rename "Duplicate specification" for option error
The other day something started going wrong with the perl rename terminal command that was pre-installed on my system; which is Ubuntu 22.04.5 LTS. When I try to use any version of the rename command ...
0 votes
0 answers
29 views
Why is set -e also ignored for functions called via command substitution [duplicate]
I've seen questions about this topic, but they talk about constructs like if or ||. I don't understand why the same behavior seem to happen for substitution ($())? $ my_function() { echo "the ...
1 vote
1 answer
114 views
Help figuring out how to handle errors in "mongodump" script
I have a simple bash script that's supposed to create a dump file from a database docker exec -i container sh -c "mongodump --archive" > \ ~/dumps/db-$(date + "%d%m%Y").dump ...
0 votes
2 answers
618 views
How to execute command if previous command fails with return code 0
I have a script which logs in to a server. Regardless of the success (i.e. whether the password is valid or not) the script will exit with return code 0, and the text: Error login failed. I'd like it ...
1 vote
0 answers
94 views
bash: is it possible to make `errexit` work inside conditionals?
Consider the following script: #!/bin/bash set -o errexit -o xtrace qux() { false echo QUX } quux() { qux ||: echo QUUX } quux Running this script produces: + quux ...
0 votes
1 answer
163 views
Some GTk3 applications aborting with BadAccess when DISPLAY=:0 but not DISPLAY=hnam.local:0 or even DISPLAY=unix:0
I've had some issues with my XQuartz environment not starting due to a bit of a freak reason that was a rather hard to figure out. It's (mostly) working again but I must have caused another regression ...
-5 votes
1 answer
86 views
virtual machine stuck [closed]
My virtual machine stuck on this and just keep downloadin for hours please solve