zsh-workers
 help / color / mirror / code / Atom feed
* <(<<<x) vs =(<<<x)
@ 2012-12-21  2:52 Stephane Chazelas
  2012-12-21  5:25 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Stephane Chazelas @ 2012-12-21  2:52 UTC (permalink / raw)
  To: zsh-workers

~$ od -tc < <(<<<a)
0000000   a  \n
0000002

~$ od -tc < =(<<<a)
0000000   a
0000001

Why the difference?

-- 
Stephane


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: <(<<<x) vs =(<<<x)
  2012-12-21  2:52 <(<<<x) vs =(<<<x) Stephane Chazelas
@ 2012-12-21  5:25 ` Bart Schaefer
  2012-12-21 15:51   ` Stephane Chazelas
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2012-12-21  5:25 UTC (permalink / raw)
  To: zsh-workers

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" ...


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: <(<<<x) vs =(<<<x)
  2012-12-21  5:25 ` Bart Schaefer
@ 2012-12-21 15:51   ` Stephane Chazelas
  0 siblings, 0 replies; 3+ messages in thread
From: Stephane Chazelas @ 2012-12-21 15:51 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-21 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-21  2:52 <(<<<x) vs =(<<<x) Stephane Chazelas
2012-12-21  5:25 ` Bart Schaefer
2012-12-21 15:51   ` Stephane Chazelas

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).