Live data from Hacker News

I wrote an bash enumerator because I was sick of xargs

numerlab.org

101–110 of 202 posts

Re: I wrote an bash enumerator because I was sick of xargs

#101

In this thread: bash experts with arcane knowledge, unintentionally demonstrating how awful bash is. The obvious solution would be to use something more sane, like PowerShell or nushell, but instead old experts will always defend the skills they have honed for years, while criticizing anything that's different.

I was the kind of shell guru whose teeth itched when they saw someone doing `grep | awk`. Then I had to try and bring Windows into a Mac+Linux CI system under Jenkins groovy files that were full of `"""sh` fragments, shell scriptlets wrapping python, etc, etc, and I don't bat (I don't groovy either).

Option 1: Learn to bat and try to translate. Hmm. No. Just no Option 2: ?

Pwsh core had just come out. My immediate thought was that it would be great material for an anti-MS-ragging blog post, but then a line leapt out at me from one article I was glossing over: "... POSIX Terminal Shell Spec ...".

I still wanted that anti-MS-ragging blog material, so I decided to try and use Pwsh as a Rosetta stone until I got to a point I could convert to a real language.

But things just began to click for me. It was like going from Perl to Python - suddenly everything is an object and you can interact with everything* that way.

There's no need for grep or awk or sed in pwsh, because the output of a shell command is an object -- a string (or []byte). It has methods.

(netstat -an).replace("192.168.86.", "10.0.100.")

6 years later, pwsh is the default shell on my Mac, Ubuntu boxes, lab vms, ... everything but my docker containers unless I'm feeling feisty.

Re: I wrote an bash enumerator because I was sick of xargs

#102
post #101

In this thread: bash experts with arcane knowledge, unintentionally demonstrating how awful bash is. The obvious solution would be to use something more sane, like PowerShell or nushell, but instead old experts will always defend the skills they have honed for years, while criticizing anything that's different.

I was the kind of shell guru whose teeth itched when they saw someone doing `grep | awk`. Then I had to try and bring Windows into a Mac+Linux CI system under Jenkins groovy files that were full of `"""sh` fragments, shell scriptlets wrapping python, etc, etc, and I don't bat ( I don't groovy either). Option 1: Learn to bat and try to translate. Hmm. No. Just no Option 2: ? Pwsh core had just come out. My immediate t…

I’m curious why it’s your default on most but not all platforms?

Re: I wrote an bash enumerator because I was sick of xargs

#103

In this thread: bash experts with arcane knowledge, unintentionally demonstrating how awful bash is. The obvious solution would be to use something more sane, like PowerShell or nushell, but instead old experts will always defend the skills they have honed for years, while criticizing anything that's different.

Yes, Bash has no place in modern software engineering.

The only reasons people still use it are historical and laziness.

If it was invented today, professionals would cringe at it.

Re: I wrote an bash enumerator because I was sick of xargs

#104
post #67

> Or maybe you pipe into xargs and pray your filenames don’t have spaces… Always use -0. Most gnu utilities support it. It makes them put a null byte after every filename instead of a newline. Completely eliminates the problem of dealing with whitespace in the filenames.

For tools that don't support -0, you can add the NULs yourself without much fuss. It's a one-liner in awk/perl/sed. Very handy.

Re: I wrote an bash enumerator because I was sick of xargs

#105
post #88

Earlier quoted context omitted.

> That's common on linux. Many tools read from stdin if a file path isn't given: cat, xargs, base64, cksum, etc. No. I did pipe to stdin. It's not my first time using Linux... Here's a command line I ran right now , and the output I see: $ echo "http://www.example.com" | parallel -k -j 8 curl -s "{}" Academic tradition requires you to cite works you base your article on. [...more nonsense...] To silence this citation…

> parallel: Warning: Finding the maximal command line length. This may take up to 1 minute. > So I wait a few seconds [snip] This warning is only ever printed if running in Cygwin, not Linux or macOS or elsewhere. Cygwin is notoriously slow. # This is slow on Cygwin, so give Cygwin users a warning if($^O eq "cygwin" or $^O eq "msys") { ::warning("Finding the maximal command line length. ". "This may take up to 1 minu…

This is on MSYS2, yes, and that excuses absolutely nothing, because this shouldn't be happening in the first place for speed to be even relevant. At the risk of repeating myself thrice: the messages are confusing, the Ctrl+C handling is just utterly broken, the citation message adds to the confusion while being frankly obnoxious, and all of the delays and outputs are unnecessary in the first place as proven by literally every other program that doesn't make me wait a minute before I can use it the first time, including xargs. If Microsoft's own Windows tools did this, everybody would bash them (no pun intended) till the end of time. But since it's GNU Parallel and not Microsoft Parallel, it's Windows's fault for being slow and also my fault for having the audacity to expect better, apparently.

Re: I wrote an bash enumerator because I was sick of xargs

#106
post #63

Earlier quoted context omitted.

isn't parallel that tool that dumps some kind of begging message into your output each time you invoke it?

No? You can tell it to stop printing the citation notice.

That sounds a lot more like "yes, but..." than "no"

Re: I wrote an bash enumerator because I was sick of xargs

#107
i often find xargs ends up biting me, and i have wanted some alternative for a while... but i don't think this is the one for me.

it feel like the syntax here is odd. it still requires me to write quote my command i want to run? unfortunately i'll have to pass on this.

personally i'd want some variant where i can still auto-complete commands and have just have {} as a placeholder. (maybe time to learn how to use xargs for real?)

Re: I wrote an bash enumerator because I was sick of xargs

#108

> Consistent syntax — same {} placeholder for files, lines, ranges, or lists Inconsistent syntax native bash methods so its an additional syntax to learn. > Template mode — single-quoted commands work as shell templates: enumerate -f '*' -- 'cat {} | head -5' Passing commands a a single string is BAD. Now you have to think about escaping and quoting. What does {} get replaced with if the enumerant contains unsafe cha…

being consistent in a sea of inconsistency is a good thing, no matter how hard you try to paint otherwise. the solution have to start at some point. But the rest, yeah, scary.

Re: I wrote an bash enumerator because I was sick of xargs

#109
post #101

Earlier quoted context omitted.

I was the kind of shell guru whose teeth itched when they saw someone doing `grep | awk`. Then I had to try and bring Windows into a Mac+Linux CI system under Jenkins groovy files that were full of `"""sh` fragments, shell scriptlets wrapping python, etc, etc, and I don't bat ( I don't groovy either). Option 1: Learn to bat and try to translate. Hmm. No. Just no Option 2: ? Pwsh core had just come out. My immediate t…

I’m curious why it’s your default on most but not all platforms?

ideally containers run a single process. if you're spawning shells you're doing something wrong. and idealier, you should use just bare processes with namespaces and abandon docker.

Re: I wrote an bash enumerator because I was sick of xargs

#110
Did you write it or did Claude code slopcoded it for you? Claude is the contributor to all your other repositories. There is a world of difference between "here's a problem that I'm really concerned with and poured all my expertise to solve it" and "I told Claude to fix it for me and now I'm gonna abandon it as soon as I'm done with the HN advertising".
Post reply on HN