|
|
|
|
|
by pnt12
304 days ago
|
|
I'm not a hater, but also not the biggest fan of bash. What do you consider its pros and cons? Pros: easy to interact with different tools, included in many Unix OSs, battle tested. Cons: complex stuff gets messy, with weird syntax, hard to do logic, hard to escape everything correctly |
|
Shell operates quite naturally under stream-oriented data-centric design patterns. But that's an architectural familiar to almost nobody in our OOP- and FP-happy industry these days. Try using Python like a relational database language (e.g. SQL), and complex stuff gets messy, the syntax starts feeling hostile, logic becomes obscure, etc. The purported ickyness of shell stems not from shell per se but from trying to force it into a foreign design space.
Principles that work well with shell: Heavily normalize your data; Organize it into line-oriented tables with whitespace-separated fields; Use the filesystem as a blob store; Filenames can be structured data as well; positional parameters form a bona fide list.
> hard to escape everything correctly
IME, all of the really painful escape patterns can always be avoided. You see these a lot when people try to build commands and pass them off to exec. That's mostly unnecessary when you can just shove the arguments in the positional parameters via the set builtin: e.g.
which is functionally equivalent to It also helps to rtfm and internalize the parsing steps that happen between line of input and the eventual execve call.