Coder Social home page Coder Social logo

Comments (5)

progrium avatar progrium commented on August 30, 2024

I'm not opposed to echo in general, but I do think it's worth getting comfortable with printf rather than just assuming echo everything.

from bashstyle.

stuartpb avatar stuartpb commented on August 30, 2024

I see this style guide as being aimed toward bulletproofing the leaky, channeling-attack-prone sieve that is Bash, and not using arguments that can be interpreted as commands is a core principle of that, right up there with not using eval. (Normally, to avoid this hole, you'd use -- to separate arguments, like I was showing you the other day with set and ssh, but echo doesn't have any such mechanism.)

from bashstyle.

progrium avatar progrium commented on August 30, 2024

I just don't want to rule against echo in the simple cases where it's obviously okay. Larger systems will probably benefit from specialized output commands, perhaps wrapping printf.

from bashstyle.

stuartpb avatar stuartpb commented on August 30, 2024

I don't rule echo out either, in the sole situation where you're specifying a complete string (with any variable substitutions coming after known static text) for human messages. Those are the only places where echo is used in Plushu.

For anywhere where a string is being echoed for technical purposes, there's no reason your function should choke on arbitrary two-character strings: all non-message output is printf '%s\n' (or similar) only.

from bashstyle.

progrium avatar progrium commented on August 30, 2024

Also if it's quoted it's not an issue. And you should quote all variables. So this is basically a non-issue.

EDIT: Sorry, that's not true. But that case is now that you are outputting just -n ... I'm not going to change my behavior for a fairly obvious edge case situation like that.

from bashstyle.

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.