Robert Elz <[email protected]> writes:
[ fascinating treatise on the esoterics of shell implementations :-) ]
> If you're imagining someone grabbing that function from somewhere, and
> using it an unintended way - why would they bother? If you want a function
> which does weird things when you call it, just write the function that you
> want, and call that one instead - you can achieve whatever results you
> desire that way.
Indeed.
[ ... ]
> ps: The one thing quoting would guard against is the existence of a file,
> or files, named "names=something.jpg" in the current directory, which would
> alter the way the function works slightly, but really, I believe, just
> restricting the files selected from what was intended, to just those
> starting with "names=" -- perhaps some very clever file naming in the
> directory could make that do even weirder things.
I will claim that having the filelist function return only one
filename out of (potentially) many matches is more than a slight
alteration of the way the function works. Just because some
fat-fingered co-worker managed to drop an unfortunately named
file into a directory.
touch file1.jpg file2.jpg file3.jpg file4.jpg
touch names=file1.jpg
important_backups=$(filelist '*.jpg')
...
OTOH, as implemented, the filelist function does not handle files
with single quotes in their names, and this might be a bigger
obstacle to using this function "for real". Besides, there are
probably better ways to arrange the processing of files in a
directory. Oh well.
-jarle
--
"Whiteboards are remarkable."