this post was submitted on 13 Nov 2025
16 points (94.4% liked)
Linux
10111 readers
723 users here now
A community for everything relating to the GNU/Linux operating system (except the memes!)
Also, check out:
Original icon base courtesy of lewing@isc.tamu.edu and The GIMP
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
$() for me, to quote from
https://www.shellcheck.net/wiki/SC2006
Shellcheckis a great tool for scripting.When I'm building a new script, I usually add the following function to the script and run the function before anything else. The script will exit immediately if any issues are found so I have a chance to correct things. If no issues are found, the script will simply continue.
It's small and simple so it's easy to remove when I'm done building a script.
Shellcheck has helped me learn a lot about scripting and I strongly recommend using it too.
That's good. There are also editors that can run it for you and highlight the issues whilst you type, neovim being one.
Why wrap it in a function at all? Why not just put the if at the top of the file?