I've read up on a few answers here in reference to quoting variables on the shell. Basically, here's what I'm running:
for f in "$(tmsu files)"; do echo "${f}"; done
this has the expected outcome: a list of files. However, I'm pretty sure they're coming out as a single string. After some reading I realized that this is a zsh-ism; it deals with splitting differently than most shells.
So I fired up bash
and ran the same command. I was expecting it to split the list, but alas, I got exactly the same result. So now I'm really confused.
- Why doesn't bash behave as expected?
- How do I get zsh to split lines?
I've tried (zsh):
for f in "$(tmsu files)"; do echo "${=f}"; done
as well as
for f in "$(=tmsu files)"; do echo "${f}"; done
neither worked, so obviously I'm mis-understanding how to get zsh
to split.
What makes this even worse is at some point I had this doing exactly what I wanted it to, and I can't remember how I did that.
for f in ...
iterates over words (where "words" has a rather idiosyncratic definition). If you want to iterate over lines, do not use afor
loop; use awhile IFS= read -r ...
loop instead. – Gordon Davisson Aug 08 '21 at 07:07