|
|
|
|
|
by bonoboTP
2092 days ago
|
|
All this is horrible incidental complexity stemming from absolute madhouse insane splitting and substitution rules in shell languages. Splitting on spaces, expanding asterisks, shell scripting is a minefield. You would basically never want any splitting to happen. Applications like reading a CSV by splitting using IFS are dirty hacks, that break with the slightest additional file parsing complexity (escapes, quoting etc). In Python you can just do `os.listdir('.')` and it will actually do what you want. No 5 layers of "oh, actually" and "yes, but what if", which inevitably happen in threads discussing the simplest shell operations. It just works as intended. If you only want the files and not the directories, you can do `filter(os.path.isfile, os.listdir('.'))`. There is no reason to use shell scripts for anything more complex than a few lines or for one-off interactive work. |
|