5 ms·
Some of these are why I bail for a “real language” in many seemingly simple scenarios. As soon as I care about datetimes, it’s just easier to use stat() and a
by salmo 5y ago
Some of these are why I bail for a “real language” in many seemingly simple scenarios.
As soon as I care about datetimes, it’s just easier to use stat() and a proper datetime API.
I can treat filenames as byte arrays and translate to Unicode or let the language do it for me.
In dire circumstances, find … -print0 | xargs -0 second_script is usually my fallback, but that has pitfalls as well.
Go has been a blessing there for me, not having to rely on a runtime across diverse hosts. But that’s a preference and doesn’t help on old kernels w/o epoll().
So many battle scars from inconsistency in Bash and GNU utilities over the years, especially on Unixes’ bundled versions (Solaris, etc) or supporting GNU, BSD, SysV, and HP-UX in the same script. Used to deploy a ksh88(ish) on all for SOME consistency.
Luckily now I’m not supporting anything but Linux anymore. When I can’t Go, then I just hijack some tool’s bundled Ruby (eg Puppet), Python, etc when I have to handle that and stick to the standard library.
I am too lazy to C these days like I used to. I’m usually dealing with an emergency (looking at you log4j) and don’t have the cycles to cover the gotchas there.
- chasil 5y agoAny POSIX system has an easy way to remove a file with a malformed/hostile name. Determine the inode number with "ls -li", then remove it with "find . -inum # -delete" to remove it. The GNU stat utility makes finding the inode slightly easier. This method is preferable when there is any doubt of wildcard expansion.
- scbrg 5y agoUnless I'm mistaken, POSIX find does not have -delete
- chasil 5y agoAlas, you are right, my mistake. It doesn't have inum either. Those GNUisms do creep in. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/f...
- cogburnd02 5y agoGNU ls also has options to automatically add quoting to its output.
- 10000truths 5y agoIt might not be in the standard, but pretty much every implementation that I know of supports it - GNU, BSD, Solaris, even busybox and toybox.
- herpderperator 5y ago> In dire circumstances, find … -print0 | xargs -0 second_script is usually my fallback, but that has pitfalls as well. What are the pitfalls?