<story><title>The Beauty of Unix Pipelines</title><url>https://prithu.xyz/posts/unix-pipeline/</url></story><parent_chain><item><author>enriquto</author><text>&amp;gt; because spaces are a reasonable thing to put in a filename unless you&amp;#x27;re on a Unix system.&lt;p&gt;Putting spaces on a filename is atrocious and should be disallowed by modern filesystems.  It is like if you could put spaces inside variable names in Python.  Ridiculous.</text></item><item><author>jcranmer</author><text>There&amp;#x27;s a certain irony in responding to criticism of that which you&amp;#x27;re extolling by saying not to use it.&lt;p&gt;And the only reason I might be pushed down that path is because the task I&amp;#x27;m working on happens to involve filenames with spaces in them (without those spaces, the code would work fine!), because spaces are a &lt;i&gt;reasonable&lt;/i&gt; thing to put in a filename unless you&amp;#x27;re on a Unix system.</text></item><item><author>gorgoiler</author><text>To criticize sh semantics without acknowledging that C was &lt;i&gt;always there when you needed something serious&lt;/i&gt; is a bit short sighted.&lt;p&gt;There are two uses of the Unix “api”:&lt;p&gt;[A] Long lived tools for other people to use.&lt;p&gt;[B] Short lived tools one throws together oneself.&lt;p&gt;The fact that most things work most of the time is why the shell works so well for B, and why it is indeed a poor choice for the sort of stable tools designed for others to use, in A.&lt;p&gt;The ubiquity of the C APIs of course solved [A] use cases in the past, when it was unconscionable to operate a system without cc(1).  It’s part of why they get first class treatment in the Unix man pages, as old fashioned as that seems nowadays.</text></item><item><author>jcranmer</author><text>&amp;gt; (1) everything is text&lt;p&gt;And lists are space-separated. Unless you want them to be newline-separated, or NUL-separated, which is controlled by an option that may or may not be present for the command you&amp;#x27;re invoking, and is spelled completely differently for each program. Or maybe you just quote spaces somehow, and good luck figuring out who is responsible for inserting quotes and who is responsible for removing them.</text></item><item><author>gorgoiler</author><text>Pipes are wonderful!  In my opinion you can’t extol them by themselves.  One has to bask in a fuller set of features that are so much greater than the sum of their parts, to feel the warmth of Unix:&lt;p&gt;(1) everything is &lt;i&gt;text&lt;/i&gt;&lt;p&gt;(2) everything (ish) is a &lt;i&gt;file&lt;/i&gt;&lt;p&gt;(3) including &lt;i&gt;pipes&lt;/i&gt; and &lt;i&gt;fds&lt;/i&gt;&lt;p&gt;(4) every piece of software is accessible as a file, invoked at the &lt;i&gt;command line&lt;/i&gt;&lt;p&gt;(5) ...with local &lt;i&gt;arguments&lt;/i&gt;&lt;p&gt;(6) ...and persistent globals in the &lt;i&gt;environment&lt;/i&gt;&lt;p&gt;A lot of understanding comes once you know what execve does, though such knowledge is of course not necessary.  It just helps.&lt;p&gt;Unix is seriously uncool with young people at the moment.  I intend to turn that around and articles like this offer good material.</text></item></parent_chain><comment><author>necrotic_comp</author><text>At Goldman, the internal language Slang has spaces in variable names. It&amp;#x27;s insane at first glance and I got into an argument with my manager about why in the world this was acceptable, and he could give me no other answer than &amp;quot;this is the way it is&amp;quot;.&lt;p&gt;But when you realize that space isn&amp;#x27;t a valid separator between token, seeing things like &amp;quot;Class to Pull Info From Database::Extractor Tool&amp;quot; actually becomes much easier to read and the language becomes highly expressive, helped somewhat by the insane integration into the firm&amp;#x27;s systems.&lt;p&gt;I was on your side until I tried it, but it can actually be quite useful, esp. if everything is consistent.</text></comment>
<story><title>The Beauty of Unix Pipelines</title><url>https://prithu.xyz/posts/unix-pipeline/</url></story><parent_chain><item><author>enriquto</author><text>&amp;gt; because spaces are a reasonable thing to put in a filename unless you&amp;#x27;re on a Unix system.&lt;p&gt;Putting spaces on a filename is atrocious and should be disallowed by modern filesystems.  It is like if you could put spaces inside variable names in Python.  Ridiculous.</text></item><item><author>jcranmer</author><text>There&amp;#x27;s a certain irony in responding to criticism of that which you&amp;#x27;re extolling by saying not to use it.&lt;p&gt;And the only reason I might be pushed down that path is because the task I&amp;#x27;m working on happens to involve filenames with spaces in them (without those spaces, the code would work fine!), because spaces are a &lt;i&gt;reasonable&lt;/i&gt; thing to put in a filename unless you&amp;#x27;re on a Unix system.</text></item><item><author>gorgoiler</author><text>To criticize sh semantics without acknowledging that C was &lt;i&gt;always there when you needed something serious&lt;/i&gt; is a bit short sighted.&lt;p&gt;There are two uses of the Unix “api”:&lt;p&gt;[A] Long lived tools for other people to use.&lt;p&gt;[B] Short lived tools one throws together oneself.&lt;p&gt;The fact that most things work most of the time is why the shell works so well for B, and why it is indeed a poor choice for the sort of stable tools designed for others to use, in A.&lt;p&gt;The ubiquity of the C APIs of course solved [A] use cases in the past, when it was unconscionable to operate a system without cc(1).  It’s part of why they get first class treatment in the Unix man pages, as old fashioned as that seems nowadays.</text></item><item><author>jcranmer</author><text>&amp;gt; (1) everything is text&lt;p&gt;And lists are space-separated. Unless you want them to be newline-separated, or NUL-separated, which is controlled by an option that may or may not be present for the command you&amp;#x27;re invoking, and is spelled completely differently for each program. Or maybe you just quote spaces somehow, and good luck figuring out who is responsible for inserting quotes and who is responsible for removing them.</text></item><item><author>gorgoiler</author><text>Pipes are wonderful!  In my opinion you can’t extol them by themselves.  One has to bask in a fuller set of features that are so much greater than the sum of their parts, to feel the warmth of Unix:&lt;p&gt;(1) everything is &lt;i&gt;text&lt;/i&gt;&lt;p&gt;(2) everything (ish) is a &lt;i&gt;file&lt;/i&gt;&lt;p&gt;(3) including &lt;i&gt;pipes&lt;/i&gt; and &lt;i&gt;fds&lt;/i&gt;&lt;p&gt;(4) every piece of software is accessible as a file, invoked at the &lt;i&gt;command line&lt;/i&gt;&lt;p&gt;(5) ...with local &lt;i&gt;arguments&lt;/i&gt;&lt;p&gt;(6) ...and persistent globals in the &lt;i&gt;environment&lt;/i&gt;&lt;p&gt;A lot of understanding comes once you know what execve does, though such knowledge is of course not necessary.  It just helps.&lt;p&gt;Unix is seriously uncool with young people at the moment.  I intend to turn that around and articles like this offer good material.</text></item></parent_chain><comment><author>outadoc</author><text>You should take a stroll in the real world sometime, where spaces and Unicode exists :)</text></comment>