Answer the question
In order to leave comments, you need to log in
How to properly handle errors in bash scripts?
How to properly handle errors in autorun scripts? I have such a problem: There is a script for example mounting a hard disk at system startup. But sometimes there is no hard drive, and when the OS is loaded, the script generates an error, and the operating system does not load any further. And you can boot only if you insert this disk. How to write a script so that if, for example, something goes wrong, the system boots further, and does not get stuck and wait for this disk to appear?
Well, I'm interested in a couple of lines of code that can be added to the script, and write the code that I need inside, and if something goes wrong, it will just load further, possibly with an error message displayed in the log. Like in C# try/catch block for example
Answer the question
In order to leave comments, you need to log in
tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_02.html
And there is no universal check for any error? Like this?
if ! do-something ; then
echo 'do-something failed'
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question