yes produces a stream of "y" chars, or other requested.
If Unixen have a pseudodevice for random numbers, why not useful streams like this too?
yes produces a stream of "y" chars, or other requested.
Precisely because of that. See yes(1) (which can repeat strings, not necessarily a single character - followed by newline).
It would be unpractical to have many devices, like /dev/repeatY to repeat Y, /dev/repeatO to repeat O etc.
Indeed, if you just want to get repeated zero bytes, consider /dev/zero (see zero(4))
BTW, on Linux, you could easily write your own kernel module implementing /dev/repeatY. But it is probably not worth the effort.
(so the why is also perhaps an historical reason)
Unixen have a pseudodevice for random numbers
These are probably much more difficult to get than a flow of constant bytes, and much more useful (and requires in practice some hardware support). See random(4) and this question. Read also myths about /dev/urandom
yes program can write arbitrary strings is a valid argument why there should be a yes program; not so much that there should not be a /dev/yes. It would be trivial to make a family of /dev/zero clones that provide arbitrary byte values.
/dev/repeat0x00, /dev/repeat0x01, .... /dev/repeat0xfe, /dev/repeat0xff? I feel that would be too much (especially in the previous century)
mknod /dev/zero c 42 0 and mknod /dev/yes c 42 121 (at least as a matter of principle). The modification to the /dev/zero driver — and I estimate that it would be a one-line change — wouldn’t require the user / administrator to instantiate all 256 nodes in /dev. Alternatively, we could make /dev/repeat/0x00 through /dev/repeat/0xFF and then link to the ones we want. There’s lots of clutter under /dev/char and /dev/disk, and it doesn’t bother anybody.
yes helloworld to be done by a device, it could be more difficult. I really think the reason is mostly historical: in the 1980s, 256 device inodes was not unsignificant
/dev/randoma device file and not just a program that runs the very same CSPRNG in application space and writes to standard output. Not Why isn't everything like this all in the kernel? which is obvious, but Why is this in the kernel at all?/dev/randomis not the best comparison;/dev/zerois the same asyesexcept it provides nulls instead ofybytes.