Live data from Hacker News

The Beauty of Unix Pipelines

prithu.xyz

221–230 of 388 posts

Re: The Beauty of Unix Pipelines

#221

Earlier quoted context omitted.

The fact that filename can contain anything except NULL/slash is really pain. I often write a shell script that treats LF as separator but I know it's not good.

filenames are variable names. Choosing good filenames is the first step in writing a nice shell script in a situation that you control.

It's sometimes in control or out of control. Writing script in defensive way is better for security if filename is out of control.

Re: The Beauty of Unix Pipelines

#222

Earlier quoted context omitted.

To criticize sh semantics without acknowledging that C was always there when you needed something serious is a bit short sighted. There are two uses of the Unix “api”: [A] Long lived tools for other people to use. [B] Short lived tools one throws together oneself. 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 desig…

There's a certain irony in responding to criticism of that which you're extolling by saying not to use it. And the only reason I might be pushed down that path is because the task I'm working on happens to involve filenames with spaces in them (without those spaces, the code would work fine!), because spaces are a reasonable thing to put in a filename unless you're on a Unix system.

Choosing space as a separator is a useful convention that saves you typing in additional code afterwards if you want to run a short command.

It's like there is a shortcut that some people use that you want to wall in because it doesn't look pretty to you.

Re: The Beauty of Unix Pipelines

#223

Earlier quoted context omitted.

> (2) everything (ish) is a file I'm not all that knowledgable about Unix history, but one thing that has always puzzled me was that for whatever reason network connections (generally) aren't files. While I can do: cat to read from a serial device, I've always wondered why I can't do something like: bind /tmp/mysocket 12.34.56.78 80 cat It is weird that so many things in Unix are somehow twisted into files (/dev/fb0?…

Sounds like you want netcat?

Or potentially even socat (http://www.dest-unreach.org/socat/), which could be used (among many other things) to model the use case of GP, forwarding a socket to a pipe.

Re: The Beauty of Unix Pipelines

#224

I think there's an interesting inflection point between piping different utilities together to get something done, and just whipping up a script to do the same thing instead. First I'll use the command line to, say, grab a file from a URL, parse, sort and format it. If I find myself doing the same commands a lot, I'll make a .sh file and pop the commands in there. But then there's that next step, which is where Bash…

Bash has perfectly functional if, while and for constructs.

Re: The Beauty of Unix Pipelines

#226
post #180

Earlier quoted context omitted.

I guess I am one of the young kids who think the unix command line is wicked cool. It makes the user experience on my laptop feel so much more powerful.

Me too. Especially since I can regularly hit 100 WPM when typing, but I'm a terrible shot with the mouse - not to mention the fact that you can get really nice and satisfying keyboards (I use an IBM Model M at home and a CODE Cherry MX Clear at college) but mice are all kind of the same, and you have to move your hand a lot to get there. On that last point, my mouse hand gets wrist pain consistently way more than my…

Ditto.

For projects where I must work in Windows my secret weapon is WSL + tmux + fish + vim for everything without a strict Visual Studio dependency.

Re: The Beauty of Unix Pipelines

#227

Earlier quoted context omitted.

This is a nice feature of make. People who put spaces on filenames are justly punished by not being given the goodness of make.

I can't tell if you're being sarcastic but this can result in innocent users who don't even know this fact to suddenly overwrite or wipe their files when trying to build someone's project.

Nobody is innocent if they have filenames with spaces in their systems! /s

Re: The Beauty of Unix Pipelines

#228

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: (1) everything is text (2) everything (ish) is a file (3) including pipes and fds (4) every piece of software is accessible as a file, invoked at the command line (5) ...with local arguments (6) ...and persistent globals in…

Everything is a file until one needs to do UNIX IPC, networking or high performance graphics rendering.

Re: The Beauty of Unix Pipelines

#229
post #139

Earlier quoted context omitted.

try powershell, its on linux too

Indeed, if it wasn’t for its reliance on .NET, it looks like PowerShell could be a massive improvement over Unix shell.

Some consider not relying on C a massive improvement.

Re: The Beauty of Unix Pipelines

#230
post #96

Earlier quoted context omitted.

My sense is that people do think Linux is "cool" (it's certainly distinguished in being free, logical, and powerful), but its age definitely shows. My biggest pain points are: - Bash is awful (should be replaced with Python, and there are so many Python-based shells now that reify that opinion) - C/C++ are awful - Various crusty bits of Linux that haven't aged well besides the above items (/usr/bin AND /usr/local/bin…

- Python as a shell would be the worst crapware ever. Whitespace syntax, no proper file autocompletion, no good pipes, no nothing. Even Tclsh with readline would be better than a Python shell. - By mixing C and C++ you look like a clueless youngster. - /usr/local is to handle non-base/non-packages stuff so you don't trash your system. Under OpenBSD, /usr/local is for packages, everything else should be under /opt or…

The ISO C and C++ papers are full of C/C++ references, are the ISO masters clueless youngsters?

Or for that matter the likes from Apple, Google and Microsoft?

Post reply on HN