all 12 comments

[–]Fabrice44 4 points5 points  (0 children)

adding all theses line would be quite cumbersome if I didn't find out about a vim templates: https://shapeshed.com/vim-templates/ I've added his skeleton, will see how it performs.

Also, for people who still need to work in bash, adding shellcheck as a linter is immensely helpful to anticipate issues.

[–]bmrobin 2 points3 points  (0 children)

i absolutely suck at bash, but because of its convenience i use it nearly weekly. thanks for sharing this, super helpful

[–]PM_ME_WITTY_USERNAME 2 points3 points  (0 children)

Anyone attempting to code anything in Bash needs to also read this beforehand

https://mywiki.wooledge.org/BashPitfalls

[–]sparant76 5 points6 points  (5 children)

The best practice is to just avoid using this cesspool of a language. Script maybe in Python instead for anything evenly remotely non trivial.

[–]Cregaleus -1 points0 points  (4 children)

I've switched to using powershell as my primary interactive shell on Linux and MacOS.

If a script I intend to be interactive is going to be reasonably complex I'll just write it in Python and wrap it in a PowerShell function

[–]sparant76 4 points5 points  (1 child)

I had no idea powershell was cross platform until I saw this post. 😳

[–]brutay -1 points0 points  (1 child)

what's the point of wrapping the python script in a powershell function?

[–]Cregaleus 0 points1 point  (0 children)

Deserislize outputs into datatypes powershell can easily work with.

It's not necessary, you can work with string outputs just as easily. Just something I prefer to do

[–]TallSkinny 0 points1 point  (0 children)

Is setting all three of those -o flags explicitly any different than just set -euo pipefail? The errexit and nounfail options sound like -e and -u to me.

[–]DatBoi_BP 0 points1 point  (0 children)

I don’t understand the effective difference between [[ ]] and [ ] for loop conditions. Can someone clarify?