Timeline for Why is using a shell loop to process text considered bad practice?
Current License: CC BY-SA 4.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 18, 2023 at 11:32 | comment | added | Vilinkameni | There is nothing inherently wrong with shell loops, but there is with using them for parsing files. The list of things which are wrong about using them for parsing files, along with the explanation of why they are wrong, is a part of the accepted answer. Sure, they might work, but with listed drawbacks. Often there is a simpler solution, which also avoids the drawbacks. | |
| Mar 16, 2023 at 22:22 | history | edited | Keith Thompson | CC BY-SA 4.0 |
added 328 characters in body
|
| Mar 16, 2023 at 20:48 | comment | added | r_31415 | I don't understand why you continue arguing about this irrelevant issue. I didn't acknowledge that in my answer or as a reply to your comment precisely because it was not worth my time, and I'm sure it is not worth your time either, so just let it go. | |
| Mar 16, 2023 at 20:40 | comment | added | Keith Thompson |
You didn't acknowledge it in your answer, which is what matters. You list 5 things to consider, but you don't include the fact that *.txt doesn't match files starting with ..
|
|
| Mar 16, 2023 at 20:30 | comment | added | r_31415 | I acknowledged both are not the same. Does it matter in the context of this answer? No. You can downvote all you want. I'm not even participating in the site anymore, so you're free to waste your time here on my behalf :) | |
| Mar 16, 2023 at 19:19 | comment | added | Keith Thompson |
You presented a code snippet using find, then you presented a second code snippet using *.txt. The two snippets are not equivalent, and you refuse to acknowledge that in your answer. Yes, the second snippet can be useful if you happen to know that there are no files with names starting with . and ending with .txt, but users should be aware of that issue. I didn't downvote before, but I will now.
|
|
| Mar 16, 2023 at 8:58 | comment | added | r_31415 | Yes, I know you didn't downvote. My answer was not a reply to your comment, which is much older than the recent downvote. Maybe you're nitpicking a little bit on the differences in those code snippets, but as I said, that was really not the point of my answer, so I didn't think it was necessary to change it. | |
| Mar 15, 2023 at 20:40 | comment | added | Keith Thompson |
I fail to see the irony. You listed several things to consider when replacing find with a shell loop, but you didn't consider the behavior on files and directories whose name starts with a dot. There is a real difference in the behavior between your two code snippets, and that's very relevant to the point of your answer. (BTW, I didn't downvote.)
|
|
| Mar 15, 2023 at 20:20 | comment | added | r_31415 | You have to appreciate the irony of people downvoting, precisely making the point I warned about in the answer. If the reason is the previous comment, I didn't reply because that @KeithThompson's objection was not the point of this answer. | |
| Dec 23, 2022 at 20:17 | comment | added | Keith Thompson |
Your first two examples are not equivalent. find recurses into subdirectories, and for file in *.txt skips files whose names start with a dot.
|
|
| Jul 27, 2022 at 20:15 | history | edited | r_31415 | CC BY-SA 4.0 |
clarify last sentence
|
| Jul 27, 2022 at 20:05 | history | edited | r_31415 | CC BY-SA 4.0 |
deleted 1 character in body
|
| Jul 27, 2022 at 20:00 | history | answered | r_31415 | CC BY-SA 4.0 |