4 ms·
I think you fail on two software engineering principles: * http://en.wikipedia.org/wiki/KISS_principle http://en.wikipedia.org/wiki/KISS_principle * you shoul
by webreac 14y ago
I think you fail on two software engineering principles:
* http://en.wikipedia.org/wiki/KISS_principle http://en.wikipedia.org/wiki/KISS_principle
* you should adapt the way you think about programming to the language you are using. This is shell, not Ada.
- jcurbo 14y agoSure, but what's wrong with his approach? POSIX sh supports all the things you need to do 'if GNU grep run this, else if BSD grep run that' - functions, case statements, conditionals. He's not talking about building up major libraries in shell, just wrapping the invocations in functions based on the environment you're in.
- npsimons 14y agoUnfortunately, taken as a whole (eg, not just blithely ignoring POSIX, or systems that don't support it, or systems that don't support long options), portable shell is a big mess. Keeping it simple would be nice, but may not be possible, depending on your goals ("make everything as simple as possible, but no simpler"). So you want to write some script that will only ever run on systems with GNU utilities installed, and you never ever plan on porting it? Fine. Just do the world (and yourself) a favor and be aware of and admit that fact upfront. And if you're going to break POSIX compatibility anyway, it would be nice if you use the long options for better readability.