diff --git a/homepage/knowledge/cat.html b/homepage/knowledge/cat.html index e4d41f9..e98f4e4 100644 --- a/homepage/knowledge/cat.html +++ b/homepage/knowledge/cat.html @@ -68,7 +68,7 @@ window.load_highlighting = function(language){

The POSIX standard as of 2003 requires only the option -u to be implemented, which prevents cat from buffering its output - on some systems, cat buffers its output in 512-byte blocks (McIlroy), similarly to dd’s default as defined by POSIX (“dd(1p)”), though most currently popular cat implementations do this by default and ignore the -u flag altogether (busybox, GNU coreutils). POSIX doesn’t mandate buffering by default - specifically, -u has to guarantee that the output is unbuffered, but cat doesn't have to buffer it in the first place and can ignore -u in that case.

This is a POSIX-compatible implementation of UNIX cat with no additional features nor buffered output in C:

-

+

 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -164,7 +164,7 @@ main(int argc, char *argv[]){
 
 

It’s worth noting that this concept of cat as a utility that sequentially prints given files to standard output means cat can be replaced by a simple shell script that does the same using dd and printf; cat as defined by POSIX is actually totally redundant to other POSIX utilities. Here’s the shell script:

-

+

 #!/bin/sh
 
 # dd_ is used so that dd can easily be re-defined