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 wrote an bash enumerator because I was sick of xargs
181–190 of 202 posts
Re: I wrote an bash enumerator because I was sick of xargs
#182In 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.
No, there are two problems here: 1. Things have developed over time. Bash and other shells weren't always this way. If you have ever touched different shells, awk, sed and so on and then touch perl you see how it is basically just the glue between the other tools put into one language. 2. The majority of scripts is written in sh or bash. So these shells won't go away anytime soon and any newcomer will be confronted w…
Possibly more for DevOps than a dev.
Re: I wrote an bash enumerator because I was sick of xargs
#183Earlier quoted context omitted.
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.
My main shell isn't even bash, I go with zsh, but if I'm writing a script for general use I go with bash.
Re: I wrote an bash enumerator because I was sick of xargs
#184In 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 always avoid Bash I prefer Almquist (ash), eg., NetBSD sh, Debian sh with tab completion, busybox ash, etc. Powershell must be slow and/or bloated like Bash; someone wrote xargs in C++ for Windows: https://github.com/idigdoug/TextTools/tree/main/wargs
Given that its manpage states that Bash is slow, perhaps it is not well-suited to be a scripting shell (cf. an interactive shell)
Re: I wrote an bash enumerator because I was sick of xargs
#185Or maybe use: `find ... -print0 | xargs -0 ...`
I guess you're still hoping your filenames don't contain an ASCII NUL, although that's a fairly reasonable assumption for all but the most paranoid use-cases.
Re: I wrote an bash enumerator because I was sick of xargs
#186In 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.
for f in *.txt; do
wc -l "$f"
done
Or this?
find . -name '*.sh' -exec wc -l {} +
Or maybe you pipe into xargs and pray your filenames don't have spaces:
find . -name '*.log' | xargs rm
Is that "software engineering"Looks more like "system administration"
Re: I wrote an bash enumerator because I was sick of xargs
#187> 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.
No dependency on GNU required anymore, POSIX 2024 supports it: https://blog.toast.cafe/posix2024-xcu#the-null-option
Re: I wrote an bash enumerator because I was sick of xargs
#188Not sure I see the point of this. Remembering a bunch of options on one tool is no better than a bunch of tools/constructs? Especially if the latter are useful elsewhere. And it can't be used for scripts unless you start shipping it alongside, which… nah. Just go with foo | while read X; do bar "$X"; done
Yes, I think the author is just showing their ignorance, not actually doing anything about that ignorance, and re-inventing the wheel: $ find /path -name "*.pdf" -print0 | xargs -0 -I {} echo "Processing: {}" # handles paths properly, obviates the need to write anything new whatsoever Seriously kids, learn your tools and check yourself before you wreck yourselves writing tools that really, really don't need to be wri…
Re: I wrote an bash enumerator because I was sick of xargs
#189Earlier quoted context omitted.
This one doesn't need xargs. find . -name '*.log' -delete
THANK YOU. I kept nodding along to all of the xargs comments, thinking “sure, but what about the even easier solution?”
#order files from different levels in a file hierarchy by size:
find . -type f -maxdepth 1 -exec ls -hlrS {} +
#output metadata for each file sequentially
find . -type f -maxdepth 1 -exec file {} \;Re: I wrote an bash enumerator because I was sick of xargs
#190Earlier quoted context omitted.
Shells imo are legacy on legacy, I like bash and zsh, they’re nonsensical but they work. Powershell is undoubtedly saner, but I hate it. I think the whole concept could be rewritten from the ground up to be modern, but reaching critical mass and mvp is too damn difficult, and the majority of mac/Linux users probably don’t want it.
If you build it and it's better, they will come. None of us here are building it.