Git Product home page Git Product logo

Comments (5)

Ballasi avatar Ballasi commented on August 18, 2024 3

This is happening due to the fact that echo behaves differently between bash and dash:

 $ cat /tmp/test.sh
#/bin/sh
echo "One\nTwo"
 $ bash /tmp/test.sh
One\nTwo
 $ dash /tmp/test.sh
One
Two

and from what I can read, jq is following JSON guidelines, which means forbidding multi-line strings with double quotes.

On bash, it works fine as the JSON given has a plain \n, whereas on dash, it has a literal newline, which breaks the program.

I'd say that there is no real reason to send the data from the plain JSON files to stdout when jq already can parse from a file via CLI. I published a fix in #23.

From Wikipedia:

Nowadays, several incompatible implementations of echo exist on different operating systems (often several on the same system), some of them expanding escape sequences by default, some of them not, some of them accepting options (the list of which varying with implementations), some of them not.

The POSIX specification of echo leaves the behaviour unspecified if the first argument is -n or any argument contain backslash characters while the Unix specification (XSI option in POSIX) mandates the expansion of (some) sequences and does not allow any option processing. In practice, many echo implementations are not compliant in the default environment.

Because of these variations in behaviour, echo is considered a non-portable command on Unix-like systems and the printf command (where available, introduced by Ninth Edition Unix) is preferred instead.

from xdg-ninja.

b3nj5m1n avatar b3nj5m1n commented on August 18, 2024

That's pretty weird, what do you have /bin/sh symlinked to?

from xdg-ninja.

luni3359 avatar luni3359 commented on August 18, 2024

It's linking to /bin/dash.

from xdg-ninja.

b3nj5m1n avatar b3nj5m1n commented on August 18, 2024

I don't have any experience with that unfortunately, maybe @Ballasi could take a look at this as well?

from xdg-ninja.

luni3359 avatar luni3359 commented on August 18, 2024

I'm using KDE Neon, which is based on Ubuntu. Please let me know if you want to know any more details.

from xdg-ninja.

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.