Live data from Hacker News

I wrote an bash enumerator because I was sick of xargs

numerlab.org

161–170 of 202 posts

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

#161
post #118

I lol'd, but do you think this is valid? https://github.com/wallach-game/bashumerate/pull/1/files to me looks like a right solution, even if I was also tired of writing for loops by hand usually

Some of these are wrong, as standard shell globs don't traverse directories. For instance the first example should be: ls **/*.sh I think that would work in Bash just as well as using find. But yeah, even in POSIX it feels redundant when we already have find, seq, grep and whatnot.

I thought I knew every nook and cranny of bash, but somehow never noticed the globstar option added in bash 4.0.

https://www.linuxjournal.com/content/globstar-new-bash-globb...

https://www.gnu.org/software/bash/manual/bash.html#Pattern-M...

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

#162

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 is filled with footguns and is awful due to that. However, it's still incredibly useful as it's everywhere and has a far greater lifespan than almost anything else. You can write scripts in PowerShell or nushell, but then find that twenty years later they're no longer usable or you find a twenty year old machine that won't have PowerShell/nushell installed. It's not so much about defending arcane scripting…

You won't find bash on BSD unless someone installed it.

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

#163

If you want a shell to interact with the results, you can of course just use a (sub)shell. ls -1 ./*.sh | xargs -rd\\n sh -c 'for i in "$@" ; do ... ; done' sh 1. not strictly necessary to use -1 as I believe all common ls detect !isatty(stdout) and produce line-by-line output anyway. 2. xargs -r just doesn't run the command if there's no input, also not strictly necessary but I'm addicted to using it because it's th…

> not strictly necessary to use -1 as I believe all common ls detect !isatty(stdout) I remember, though from the dim an distant past so it could be a long-fixed bug, this not working in at least one circumstance. I've explicitly included -1 in scripted calls to ls since. Of course we are breaking the best practice rule of not trying to parse the output of ls, so problems are not unexpected… As a generally thing I lik…

I don't remember which was the odd one out, but in the 00s I was using Mac OS X and FreeBSD (and maybe some other more niche alternatives) a lot, and something didn't support xargs -0.

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

#164
post #152
post #134

Earlier quoted context omitted.

To be pendantic ls -- **/*.sh Otherwise it will fail if you've got a file named e.g. --help

So, it's essentially argument injection? I dislike these tools so much, because you need to know all these corner-cases and I don't.

Yeah, this happens broadly in shell with globbing. It's a bit ridiculous.

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

#167

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.

Given the alternative proposed by OP was more of the same but with layers on top, saying "how about just using xargs and sh anyway" is a simplification -- learn 2 tiny things vs start depending on some new tool whose only purpose is to let you avoid learning those 2 tiny things by adding template language, etc., on top? I'll learn the 2.

As for widening the scope to other tools, I've written about that on here before, how I have lots of powershell experience, some nushell, etc. I haven't become a convert (definitely not on Linux, of course occasionally on Windows).

Happy to respond to any input or anything, but you should reply directly to people if you're going to criticize them -- very poor form to blanket criticize while also taking an uncharitable read.

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

#168

Earlier quoted context omitted.

Some of these are wrong, as standard shell globs don't traverse directories. For instance the first example should be: ls **/*.sh I think that would work in Bash just as well as using find. But yeah, even in POSIX it feels redundant when we already have find, seq, grep and whatnot.

I frequently have cases where `ls **/*.png` fails because the argument list is too long. Just happened yesterday with an rm I wanted to run. Find works, but the syntax is arcane. Not bad , but unlike any other common cli tool, which makes it more difficult to remember if you haven't needed it in a while

> Find works, but the syntax is arcane.

fd is a lifesaver: https://github.com/sharkdp/fd

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

#169

Earlier quoted context omitted.

Some of these are wrong, as standard shell globs don't traverse directories. For instance the first example should be: ls **/*.sh I think that would work in Bash just as well as using find. But yeah, even in POSIX it feels redundant when we already have find, seq, grep and whatnot.

I frequently have cases where `ls **/*.png` fails because the argument list is too long. Just happened yesterday with an rm I wanted to run. Find works, but the syntax is arcane. Not bad , but unlike any other common cli tool, which makes it more difficult to remember if you haven't needed it in a while

Newer finds have a -delete option. Dunno if that's standard or some GNU addition, but it's there.
Post reply on HN