Giter VIP home page Giter VIP logo

Comments (6)

madeddie avatar madeddie commented on August 11, 2024

What weird behaviour are you seeing? Empty lines?
If so, try:
cargo run 'echo $ITEM' --for "`cat README.md`"

from loop.

Miserlou avatar Miserlou commented on August 11, 2024

Yes, I was seeing empty lines, but that fixed it. Why does the type of quote matter?

from loop.

madeddie avatar madeddie commented on August 11, 2024

That's because of your shell, probably bash.

Try echo "$TERM" and then echo '$TERM'

You'll see that the first time it outputs the value of $TERM, but the second time it outputs a literal $TERM. Double quotes allow variable substitution, single quotes prohibit.

Specifically, when you execute cargo run, the $ITEM is replaced with the value of $ITEM in the parent shell of cargo, aka, the current shell you're in, instead of the shell that loop spins up. $ITEM is most likely empty there.

The same goes for the value of `cat README.md`. This last one doesn't cause a problem though, since both outside loop and inside loop, `cat README.md` would have the same output.

Does that make sense?

from loop.

madeddie avatar madeddie commented on August 11, 2024

For more info, see for instance http://wiki.bash-hackers.org/syntax/quoting

mind you, this also goes with other advanced shell like ksh.

from loop.

Miserlou avatar Miserlou commented on August 11, 2024

Ha! Okay, thanks for explaining! I learned something new today.

from loop.

michaelmior avatar michaelmior commented on August 11, 2024

Looks like this can be closed?

from loop.

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.