1,845 karma · joined March 30, 2017
touch 'file with spaces'
for file in $(ls); do
rm -- "$file"
done
This will not work, because $(ls) will get expanded to three items, not one. rm will be called on the files "file", "with", and "spaces"...which is not what was intended.Now do this:
touch 'file with spaces'
for file in *; do
rm -- "$file"
done
This works correctly."As with many of the utilities that deal with filenames, the output of ls for multiple files or in one of the long listing formats must be used carefully on systems where filenames can contain embedded white space."
POSIX is such a system. If you try to parse the filenames output by ls, it will break when you encounter a filename with whitespace in it. Use a shell glob instead—it will actually work right.
That's the Half-Life logo, not a coincidence.
(And, just to prove how much I love Half-Life, my username is a Half-Life reference)
And this is exactly why Richard Stallman doesn't like the term. https://www.gnu.org/philosophy/open-source-misses-the-point....
0. https://dogbehaviorscience.wordpress.com/2012/09/29/100-year...
Oh, it definitely isn't: http://healthypets.mercola.com/sites/healthypets/archive/201...
(And look up an x-ray of a pug's skull, while you're at it)
The skillet (understandably) doesn't heat the top of the pizza that much. The toaster oven doesn't have that problem.
As an aside/self-plug, I wrote a blog post[0] complaining about my least-favorite Bash gotchas.
0. https://lambda.complex.rocks/2017/03/why-i-dont-like-bash/
There are some platforms (such as embedded systems) where C really is the only choice. But if you do have a choice? Then I don't think using C is a good idea.
I'm not sure if "irresponsible" is the right word, though. I think developers underestimate the risks of C's unsafety and/or overestimate their ability to properly deal with it. Hanlon's razor[0] applies.
If you actually care about memory safety—which you should, as the CVE list shows—then why not use an actual memory-safe language?
I signed up for the GitHub education pack, which provides (among other things) $50 USD in DigitalOcean credit. I spun up one of the $5/month droplets, primarily to use as an IRC bouncer. But, since I now had my own Linux server with a static IP address, I said "Why the heck not?" and bought a domain name for $10.
So now I have an IRC bouncer and a personal blog. (And a Quake 3 server...because I can)