3 ms·
> which is just layers of hacks to cover up the fact that you're just slinging strings around This is NOT true. You are slinging around FILES. They might be te
by hajile 5y ago
> which is just layers of hacks to cover up the fact that you're just slinging strings around
This is NOT true. You are slinging around FILES. They might be text and they might not be text. Nothing keeps bash from opening up a file of raw C structs and parsing out the objects to use them.
The reason this isn't done very much is because it is seldom useful. 99% of files that users want to process on the command line are human-readable text files (this is just as true on Windows as on POSIX). The rest of what is done consists mostly of piping the non-text through programs dedicated to handling complex data.
The most common use case for "objects" is parsing JSON and tools like jq exist to do this. There are also separate tools for most of the common non-text formats.
> Yes, you can accomplish anything in bash. But it's not pretty.
Powershell one-liners aren't pretty either. If you're writing complex programs on the command line, you are making a big mistake. A bug in your code could be catastrophic. Such programs need to be tested first anyway.
Shebang files have been around for decades to solve this issue. Just write your code in a "real" language like python or perl.
- legalcorrection 5y ago>Nothing keeps bash from opening up a file of raw C structs and parsing out the objects to use them ... so you're parsing strings. In bash, all values are strings (with a half-exception for the the phantasms of integers and lists).