Earlier quoted context omitted.
You mean like this? echo "message" 1>&2 Yes, that's probably a good idea, though I cannot recall this causing a problem for any script that I've written so far.
Wait, --help should print to stdout so that fancycommand --help | less works as expected. Otherwise, the help text will dump to the screen and less will erase it when it decides to redraw its empty buffer! Actual error messages should go to stderr so that I can redirect them to an error log or so I can suppress them if need be, or I could also be doing > /dev/stdout to silence normal output but I don't want errors to…
Bash code generator for command-line arguments
51–54 of 54 posts
Re: Bash code generator for command-line arguments
#52Earlier quoted context omitted.
This is nice! I suggest writing messages to standard error instead of standard output.
You mean like this? echo "message" 1>&2 Yes, that's probably a good idea, though I cannot recall this causing a problem for any script that I've written so far.
$ tens.sh --verbose 5
10
100
1000
10000
100000
Calculated 5 results
$ tens.sh --verbose 5 > results
Calculated 5 resultsRe: Bash code generator for command-line arguments
#53Earlier quoted context omitted.
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.
> but other things got complicated there, mostly running other processes, capturing their exit status, pipe-ing their output Note that Python's subprocess module [0] has received many updates since v3.5, and now I find it relatively painless. Most of the times, subprocess.check_output() or subprocess.run() will do the trick. [0]: https://docs.python.org/3/library/subprocess.html
Re: Bash code generator for command-line arguments
#54Earlier quoted context omitted.
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.
tcl is designed for this situation