Giter Site home page Giter Site logo

Bash script mode about styleguide HOT 2 CLOSED

M4rotte avatar M4rotte commented on May 23, 2024
Bash script mode

from styleguide.

Comments (2)

vapier avatar vapier commented on May 23, 2024 1

we shouldn't encourage people to think turning on set -e means they don't need to add error checking

https://mywiki.wooledge.org/BashFAQ/105

set -u seems a matter of taste. I don't know that it catches bugs that really matter. for typod vars, shellcheck is better imo, especially because it is a static analyzer.

pipefail can be a little insidious. consider tools that exit early like grep -q -- if you were piping a large file to it, it could trigger a write to a closed ("broken") pipe, but not consistently. this is a fun bug to track down.

might be worthwhile adding an appendix on these options and why we don't require them all the time.

from styleguide.

M4rotte avatar M4rotte commented on May 23, 2024

we shouldn't encourage people to think turning on set -e means they don't need to add error checking

The errexit option (set -e) clearly doesn’t prevent the need for proper error checking. I would even say it forces people not letting some silent errors here and there. I do not see how it could represent such an encouragement.

More I think about it, not exiting on error only makes sens for an interactive use of Bash, but not for a script. But it is indeed probably not always a good idea to set this option when the script is used. But during the development phase at least it is highly useful imo.

You’re right for the pipefail option. I don’t think it is as important as the errexit and nounset options.

The nounset (set -u), imho, forces user not to let “dead” code that could make the code harder to (re)read, and to always choose default value for any variable.

Thank you for your answers.

from styleguide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.