.
D 2019-04-30T18:37:12.679
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment Tcl\sbehaves\serratically\swhen\sstdout\sand\sstderr\sare\sredirected\sin\sintermediate\spipe\sstages\sof\san\sexec\scall.\r\n\r\nSuppose\sa\sprogram\scalled\s"print_stderr"\sthat\sprints\s"COUT"\sto\sstdout\sand\s"CERR"\sto\sstderr.\sThe\sfollowing\sworks\sproperly:\r\n\s%\secho\s"BLA"\s1>ble\s|\s./print_stderr\r\n\sSTDOUT\r\n\sSTDERR\r\n\s%\scat\sble\r\n\sBLA\r\n\r\nBut\swhen\swe\sremove\sthe\s"1"\sfrom\sthe\sredirection,\sthis\sis\swhat\swe\sget:\r\n\s%\secho\s"BLA"\s>ble\s|\s./print_stderr\r\n\s%cat\sble\r\n\sSTDOUT\r\n\sSTDERR\r\n\r\nThe\sproblem\salso\shappens\swhen\sredirecting\sstderr:\r\n\s%\secho\s"BLA"\s2>ble\s|\s./print_stderr\r\n\sSTDOUT\r\n\s%\scat\sble\r\n\sSTDERR\r\n\r\nNotice\show\sthe\sredirection\shappens\sfor\sthe\swhole\scommand\sand\snot\sonly\sfor\secho.\r\n\r\nThere's\sa\sspecific\sproblem\swith\s">file"\ssince\sit\sredirects\sboth\sstderr\sand\sstdout\swhen\sit\sshould\sonly\sredirect\sstdout\s(and\sonly\sfor\secho\sin\sthe\sexample!),\saccording\sto\sdocumentation:\r\n\s\s\s\s>\sfileName\r\n\s\s\s\s\s\sStandard\soutput\sfrom\sthe\slast\scommand\sis\sredirected\sto\sthe\sfile\snamed\sfileName,\soverwriting\sits\sprevious\scontents.\r\n\r\nThe\sbehaviour\sfor\sstderr\sis\sunexpected\sbut\smaybe\sunderstandable\ssince\sthe\sdocumentation\sstates:\r\n\s\s\s\s2>\sfileName\r\n\s\s\s\s\s\sStandard\serror\sfrom\sall\scommands\sin\sthe\spipeline\sis\sredirected\sto\sthe\sfile\snamed\sfileName,\soverwriting\sits\sprevious\scontents.\r\nStill,\sthis\sshould\sonly\sbe\svalid\sin\sthe\slast\sstage\sof\sthe\spipeline,\sin\smy\sopinion.\r\nConsider,\sfor\sexample,\sthe\sfollowing\sscenario:\r\n\s\s%\secho\s"BLA"\s>ble\s|\s./print_stderr\s>bli\r\n\s\s%\scat\sble\r\n\s\s%\scat\sbli\r\n\s\sSTDOUT\r\n\s\sSTDERR\r\n\r\nAll\sthese\sbehaviours\sare\svery\sdifferent\sfrom\stheir\sshell\scounterparts,\smeaning\swe\sdon't\sget\sthe\ssame\sexpressiveness\swe'd\sget\sfrom\sactually\srunning\sa\sshell\scommand.
J foundin 8.6.9
J is_private 0
J login euller
J priority 5\sMedium
J private_contact c73040ce352899ef6ad98381bd8f919cd232c428
J resolution None
J severity Minor
J status Open
J submitter euller
J subsystem 45.\sParsing\sand\sEval
J title Incorrect\shandling\sof\sredirection\sin\sprocess\spiping
J type Bug
K 204ac7df2468599bf8c82fa82a147b79a35ef1d2
U euller
Z 739d89ebe2ebb5c0f616f0983cf497f4