Bash code generator for command-line arguments
1–10 of 54 posts
Re: Bash code generator for command-line arguments
#2Re: Bash code generator for command-line arguments
#3Out of curiosity: if you (the reader) get to a point where you need more complicated and esoteric functionality that Bash can provide, do you still keep hammering at it or turn to a more capable (and readable) language?
Just wondering if people are usually working in very constrained environments where other languages aren't able to be readily used.
Re: Bash code generator for command-line arguments
#4Quite an impressive project all things considered; definitely something to keep in mind for the next project that inevitably starts out as a simple Bash script. Out of curiosity: if you (the reader) get to a point where you need more complicated and esoteric functionality that Bash can provide, do you still keep hammering at it or turn to a more capable (and readable) language? Just wondering if people are usually wo…
In the end, it was easier to hammer onto bash. Also, there are great linters for bash scripts, so things work out.
Re: Bash code generator for command-line arguments
#5Quite an impressive project all things considered; definitely something to keep in mind for the next project that inevitably starts out as a simple Bash script. Out of curiosity: if you (the reader) get to a point where you need more complicated and esoteric functionality that Bash can provide, do you still keep hammering at it or turn to a more capable (and readable) language? Just wondering if people are usually wo…
Re: Bash code generator for command-line arguments
#6Hold up. The only version of getopt with long option support is from util-linux, which fixes all the whitespace issues people were discouraging getopt for. So what's the stated goal of this project again?
Heck, you don't even need to write code to detect usage of legacy getopt. It will panic every time you use the new stuff once it sees the option to turn on escaping.
Advertise all your cool features like argument types and help generation, but not this. I don't see how writing m4 is easier than just a while-case loop, but I may try it for the extra features.
Re: Bash code generator for command-line arguments
#7Quite an impressive project all things considered; definitely something to keep in mind for the next project that inevitably starts out as a simple Bash script. Out of curiosity: if you (the reader) get to a point where you need more complicated and esoteric functionality that Bash can provide, do you still keep hammering at it or turn to a more capable (and readable) language? Just wondering if people are usually wo…
My biggest successes have been extracting these parts into very small stand-alone shell scripts which the Python application then invokes, which gives you the best of both worlds. The best example off the top of my head is `mysqldump | sed ... | gzip` with decent error handling (i.e. set -o pipefail in bash).
My environment isn't all that constrained, but I do have to deal with old Python versions (though at least I don't have to support 2.6 any more...), and a surprising amount of the features that would make replacing bash easier (subprocess.call especially) are only available fairly recently.
Re: Bash code generator for command-line arguments
#8Quite an impressive project all things considered; definitely something to keep in mind for the next project that inevitably starts out as a simple Bash script. Out of curiosity: if you (the reader) get to a point where you need more complicated and esoteric functionality that Bash can provide, do you still keep hammering at it or turn to a more capable (and readable) language? Just wondering if people are usually wo…
As soon as as the cli becomes non-trivial I switch to python and use docopt for that (really cool module btw.). Pipelining processes is not as idiomatic in Python as it is in Bash though, but everything is better than getopts. I'd rather decapitate myself with a teaspoon than using getopts.
I like it too, not least because I can use ~the same thing in multiple languages and not have to remind myself how the arg parser for language X works each time.
Re: Bash code generator for command-line arguments
#9Quite an impressive project all things considered; definitely something to keep in mind for the next project that inevitably starts out as a simple Bash script. Out of curiosity: if you (the reader) get to a point where you need more complicated and esoteric functionality that Bash can provide, do you still keep hammering at it or turn to a more capable (and readable) language? Just wondering if people are usually wo…
I've tried that path with little success. Usually, arg parsing makes me try some other language (perl, python) but other things got complicated there, mostly running other processes, capturing their exit status, pipe-ing their output etc. In the end, it was easier to hammer onto bash. Also, there are great linters for bash scripts, so things work out.