News for hackers. Stuff that matters.
Re:Bash code generator for command-line arguments by matheusmoreira on Friday October 02, 2020 @11:26AM (#24663583)
This is nice! I suggest writing messages to standard error instead of standard output.
Re:Bash code generator for command-line arguments by bxparks on Friday October 02, 2020 @11:46AM (#24663810)
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.
Re:Bash code generator for command-line arguments by xandris on Friday October 02, 2020 @12:45PM (#24664435)
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 be discarded.
Re:Bash code generator for command-line arguments by matheusmoreira on Friday October 02, 2020 @03:12PM (#24666015)
I agree. When a program is given the --help option, the usage information is the actual output.
Re:Bash code generator for command-line arguments by matheusmoreira on Friday October 02, 2020 @03:17PM (#24666069)
It allows users to easily separate messages intended for the user from output which can be consumed by other scripts.

  $ tens.sh --verbose 5
  10
  100
  1000
  10000
  100000
  Calculated 5 results

  $ tens.sh --verbose 5 > results
  Calculated 5 results