> Date: Tue, 23 Sep 2014 16:38:43 +0200 > From: Tino Didriksen <[email protected]> > To: "[email protected]" > <[email protected]> > Reply-To: [email protected] > Subject: Re: [Apertium-stuff] Why does double redirection with apertium > cleans destination file ? > > On 23 September 2014 15:51, <[email protected]> wrote: > > > echo "Here is a string to translate" | apertium sl-tl >> myfile > > > > After that, myfile countains the translation but not the previous content. > > Exactly like if simple redirection > was used. > > > > What is the reason of this bug and could it be repared ? > > > The cause is twofold: > > 1) The special file /dev/stdout is a link to /proc/self/fd/1. So far, ok. > But, when using shell redirects, /proc/self/fd/1 becomes a link to the > actual file you're outputting to. > > 2) The apertium wrapper script uses > redirection internally. So far, ok. > But, when no output file is given, apertium defaults to /dev/stdout. Thus, > >/dev/stdout is used, which becomes >/the/actual/file and thus truncates > the file regardless of whether the shell used >> > > Can it be repaired? Yes. > > The fix is that when no output file is given, just print or pass through. > Don't try to write to the special file /dev/stdout, since that may truncate > when not wanted, or if you use append open mode then it may not truncate > when actually wanted. > > -- Tino Didriksen >
With what you explained, I did it. File changed : (...)/trunk/apertium/apertium/apertium-header.sh Revision 57380. The changes are : - the two lines with OUTPUT_FILE inside get unused (in comment) - changing the way $3 is used : < OUTPUT_FILE=$3; --- > SALIDA=$3; > REDIR=">"; - everywhere >"$SALIDA" is found, replace it by $REDIR $SALIDA Note: "$SALIDA" must be changed into $SALIDA to prevent errors when this string is empty. Anyway, the only reason to write "$SALIDA" would have been to allow using hatefull filenames with spaces or other characters having a special meaning for command line inside. As at least spaces in filenames was not working before, this change is not a problem. Except for the result in the 4 last lines of the shell, I don't understand what the previous >"$SALIDA" were for. Expecially because this file is cleaned for each step of the translation. Is it to send to the result file the result of the last task working if apertium crash ? In that case, a explicit external redirection to a error file would have been enough. -------------------------------- Bernard Chardonneau (France) Phone : [33] 1 64 90 87 04 or [33] 9 72 36 32 90 GSM phone : [33] 6 49 95 13 95 Multilingual websites for my free softwares : http://libremail.free.fr and http://libremail.tuxfamily.org http://cyloop.tuxfamily.org (mainly translated with Apertium) My general website (in french only) http://bech.free.fr ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ Apertium-stuff mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/apertium-stuff
