|Perl Monk, Perl Meditation|
Re^3: Replace strings in multiple filesby afoken (Abbot)
|on Nov 13, 2012 at 17:10 UTC||Need Help??|
The answer to all of the above is glob
Most shells do expand filenames, and for the special case Win32, there is a workaround available (see also Re^3: Perl Rename). This way, the command line interface for a program is consistent across platforms.
If you pass the programs arguments to glob unconditionally, you have to quote the wildcards with every shell that expands filenames, but you must not quote them with shells that don't expand filenames.
First off, not all OS's do filename expansion. CMD.EXE doesn't, for example, at least not last time I tried.
CMD.EXE is not an operating system. It is a shell. Butt ugly, loaded with bug-compatibility back to DOS 1.0, and in desperate need of a clean rewrite, but still a shell, like its slightly uglier father command.com.
Expanding filenames does not depend on the OS. Cygwin offers a bash running on top of Windows, and I would be very surprised if it did not expand filenames. Implementing a tiny and stupid shell that does not expand filenames on Unix is no problem, but people rarely want that. It is a good homework, to understand how a shell works. And it may be useful for a restricted shell.
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)