I found myself wanting to reproduce a line of input multiple times, so
my first thought was:

echo line | yes --some-option | consumer

to make yes read the first line of stdin and replay that, but we don't
have such an option - the text to be replayed has to be passed on the
command line. I ended up doing:

yes "$(echo line)" | consumer

but wonder if it is worth adding such an option (maybe spelled
--from-file, where '--from-file=-' reads from stdin).  Using xargs for
the task is not ideal, unless we have a way to make xargs shut up about
EPIPE:

# echo line | xargs yes | head -n5
line
line
line
line
line
xargs: yes: terminated by signal 13

I guess this request also interacts with the recent question on whether
'yes' falls into the category of commands that should gain support to
output data with NUL separators rather than newlines.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to