3 ms·
This kind of goes against the fundamental nature of bash/Unix, no? Everything is text, and every program does a small text manipulation thing well. Also what w
by chadlavi 5y ago
This kind of goes against the fundamental nature of bash/Unix, no? Everything is text, and every program does a small text manipulation thing well.
Also what would be the type of a command like `echo '{"foo": "bar"}'`? Would it guess that that's JSON or just say "well it's echo therefore string"?
- traverseda 5y agoText generally needs to be formatted somehow, after all it does represent data. So how do you format the text? You can use newline-deliminated values, if your data is simple enough. This is great for things like iterating over a set of files, as each file is just a path separated by a newline. What about more complicated data though? Maybe you format the text as json? You can still use text-parsing tools like grep with it, but you can also use more specific text processing tools like JQ. "Just text" is actually pretty complicated, a CSV and a JSON file are both "just text". You've got to have some structure somewhere, even if only by convention.
- chadlavi 5y agoSure, but a program like jq will essentially throw a type error if you try to pipe it stuff that isn't in a format it can do something with. Generally speaking you're not going to get silent errors when you try to extract formatted data from plain text content. And at the point that you need types, maybe the shell isn't the place to be doing that data manipulation?
- IshKebab 5y agoThat fundamental nature is not very robust. We can do better.