Re: shell quoting (was: Improving the performance of system boot by eliding unused rc.d scripts and caching the result)

David Holland <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
On Wed, Aug 19, 2026 at 11:17:45AM +0200, Edgar Fu? wrote:
 > > like "for f in ${allf}" where the ${allf} value needs to be field split 
 > > - that's not really safe, but the alternative is messy.
 >
 > Why is that unsafe? What else could one do?

Suppose you have:

   allf=$(ls *.jpg)
   for f in $allf; do
       printf 'File: %s\n' "$f"
   done

Now imagine that the files in $CWD are foo.jpg, bar.jpg, and silly
filename with spaces.jpg...

There is no easy way to make it more robust, unfortunately.

-- 
David A. Holland
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.