#!/usr/bin/c++script // Print lines on stdout and stderr // Used to test COMMAND::run() static void gen_line (bool random, ostream &out, string_view prefix, int line_num) { string randstr; if (random) randstr = string(rand()%100+1,'X'); out << format ("{} line {}: {}\n",prefix,line_num,randstr); } #main progdesc("Generate lines on stderr and stdout"); option nbout ('n',"nbout","Number of lines generated on stdout",1,false); option nberr ('e',"nberr","Number of lines generated on stderr",1,false); option mixed ('m',"mixed","Interleave stdout and stderr",false,false); option retcode ('r',"retcode","Exit code for the script",0,false); option random ('R',"random","Produce lines with random length",false,false); if (mixed.val){ unsigned maxval = max(nbout.val,nberr.val); for (unsigned i=0; i