4 ms·
I think if you're trying to use the shell for something other than some basic program launch glue, you are doing it wrong. In C, readdir returns a perfectly us
by alayne 12y ago
I think if you're trying to use the shell for something other than some basic program launch glue, you are doing it wrong.
In C, readdir returns a perfectly usable struct dirent * with no parsing issues to worry about.
Python also provides a usable Unix layer for automation.
- todd8 12y agoEvery so often, I'll find myself frustrated with some bash script. For me, once a shell script gets to that point, it's best to rewrite it in Python. Translating a script into Python is almost fun, and I find the result much more maintainable. BTW, the original submission is great. I've written shell scripts over the years that have made this very mistake! For example doing something like: ls pj* | wc -l Which normally returns the number of pj* files, but will fail for pathological file names as the submission points out.
- cgtyoder 12y agoBingo. Also, if you're creating filenames with newline and escape chars - well, good luck with that.