I remember that when I worked at Google about a decade ago, there was this common saying: "If the first version of your shell script is more than five lines long, you should have written it in Python." I think there's a lot of truth in that. None of the examples presented in the article look better than had they been written in some existing scripting/programming language. In fact, had they been written in Python or…
Jo – a shell command to create JSON (2016)
61–70 of 100 posts
Re: Jo – a shell command to create JSON (2016)
#62I remember that when I worked at Google about a decade ago, there was this common saying: "If the first version of your shell script is more than five lines long, you should have written it in Python." I think there's a lot of truth in that. None of the examples presented in the article look better than had they been written in some existing scripting/programming language. In fact, had they been written in Python or…
> "If the first version of your shell script is more than five lines long, you should have written it in Python."
Seriously, these kind of "common knowledge", "universal truth in a sentence" sayings are often the mark of wannabe guru mid career engineers that have no clue what they are talking about.
Re: Jo – a shell command to create JSON (2016)
#63Earlier quoted context omitted.
If you're going to use string literal, then echo '{"name": "JP", "object": {"fruit": "Orange", "point": {"x": 10, "y": 20}, "number": 17}, "sunday": false}' is fine as a script
All fun and games until you need quoting. Quoting in shell scripts is already hellish enough, but layering JSON quoting on top of that is a road to madness.
Re: Jo – a shell command to create JSON (2016)
#64I remember that when I worked at Google about a decade ago, there was this common saying: "If the first version of your shell script is more than five lines long, you should have written it in Python." I think there's a lot of truth in that. None of the examples presented in the article look better than had they been written in some existing scripting/programming language. In fact, had they been written in Python or…
> there was this common saying: > "If the first version of your shell script is more than five lines long, you should have written it in Python." Seriously, these kind of "common knowledge", "universal truth in a sentence" sayings are often the mark of wannabe guru mid career engineers that have no clue what they are talking about.
Re: Jo – a shell command to create JSON (2016)
#65Earlier quoted context omitted.
All fun and games until you need quoting. Quoting in shell scripts is already hellish enough, but layering JSON quoting on top of that is a road to madness.
Combining here-string with `jq` (if you need variables), is plenty good enough. You'd need a single jq invocation.
Re: Jo – a shell command to create JSON (2016)
#66Earlier quoted context omitted.
> there was this common saying: > "If the first version of your shell script is more than five lines long, you should have written it in Python." Seriously, these kind of "common knowledge", "universal truth in a sentence" sayings are often the mark of wannabe guru mid career engineers that have no clue what they are talking about.
This is a toxic comment that adds nothing to the conversation.
Re: Jo – a shell command to create JSON (2016)
#67I remember that when I worked at Google about a decade ago, there was this common saying: "If the first version of your shell script is more than five lines long, you should have written it in Python." I think there's a lot of truth in that. None of the examples presented in the article look better than had they been written in some existing scripting/programming language. In fact, had they been written in Python or…
Re: Jo – a shell command to create JSON (2016)
#68I wonder if a formal syntax would help? Perhaps including relevant shell syntax (interpolation, subshell). It could clarify issues, and this different perspective might suggest improvements or different approaches.
Re: Jo – a shell command to create JSON (2016)
#69Earlier quoted context omitted.
If you're going to use string literal, then echo '{"name": "JP", "object": {"fruit": "Orange", "point": {"x": 10, "y": 20}, "number": 17}, "sunday": false}' is fine as a script
All fun and games until you need quoting. Quoting in shell scripts is already hellish enough, but layering JSON quoting on top of that is a road to madness.
Re: Jo – a shell command to create JSON (2016)
#70I remember that when I worked at Google about a decade ago, there was this common saying: "If the first version of your shell script is more than five lines long, you should have written it in Python." I think there's a lot of truth in that. None of the examples presented in the article look better than had they been written in some existing scripting/programming language. In fact, had they been written in Python or…
That's not a shell command any more than running "python" is. `jo` is its own executable.
And doing the sub-commands are not necessary; `jo` supports nested data natively.