Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • that last assignment in itself shouldn't give any error, it just assigns the string (without glob expansion) to FILES. depending on where and how you use it, you might get that error, possibly due to word splitting messing the result up when expanded. But you'd have to show what you're actually doing there. Commented Aug 30, 2022 at 11:01
  • 1
    Your problem with the for f in "$FILES" looks exactly the same as in the question you linked, $FILES will be a single string containing all the filenames, joined together. Commented Aug 30, 2022 at 11:02
  • @ilkkachu so for f in $files doesn't split it up, like say in python? Can you give the correct wording? Commented Aug 30, 2022 at 11:04
  • no, for f in $files does wordsplit on whitespace by default (and expand globs), but for f in "$files" doesn't. But the splitting is rife with issues, and ignores the fact that filenames can themselves contain whitespace, so it's usually best avoided. I'm not sure what Python behaviour you refer to, since something like for i in list in Python would loop over each element of the list (without textual splitting), while for i in string would loop over each character of the string (not splitting on whitespace) Commented Aug 30, 2022 at 11:07