Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: <(<<<x) vs =(<<<x)



2012-12-20 21:25:40 -0800, Bart Schaefer:
> On Dec 21,  2:52am, Stephane Chazelas wrote:
> }
> } ~$ od -tc < <(<<<a)
> } 0000000   a  \n
> } 0000002
> } 
> } ~$ od -tc < =(<<<a)
> } 0000000   a
> } 0000001
> } 
> } Why the difference?
> 
> This appears to be a side-effect of =(<<<a) being optimized for no forking
> in a manner similar to the optimization for $(<file).  The subshell spawned
> to be able to read <(<<<a) as a pipe is appending the newline.
> 
> I don't know which variation ought to be considered "correct" ...

rc's <<< didn't append that trailing newline. zsh does in every
place but =(<<<xxx) AFAICT, and so do bash and ksh93 (I suppose
they just copied zsh there), so I suppose the only sensible
thing to do now is to add it every time to be consistent as we
can't really go back and don't include it every time.

On the other hand, that would mean that we wouldn't have an
optimized way to write =(echo -n foo) any longer (probably not
too much of an issue since it's quite uncommon to have a file
without a trailing newline)

-- 
Stephane



Messages sorted by: Reverse Date, Date, Thread, Author