Spaces in filenames (was: shell script question)
Jason Stephenson
jason at sigio.com
Tue Jan 21 12:30:02 EST 2003
Check out my resume: http://www.sigio.com/~jason/resume.html
I've encountered these situations a thousand times. So, you tell
management that if they want the software to work correctly, you need to
spend an hour or two to write a wrappper script that properly cracks the
output of your proprietary command and handles spaces and other
"strange" characters in file names. It's not hard, really.
Now, it's your manager's choice. Either he lets you work on it for a
little while and gets software that actually works, or he doesn't.
Derek Martin wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Tue, Jan 21, 2003 at 11:52:49AM -0500, Jason Stephenson wrote:
>
>>By the way, it is very easy to handle spaces in file names in shell
>>scripts. Simply put double quotes (") around all variable substitutions
>>that will be used as strings. Most shells even do the right thing with
>>numeric values bracketed by double quotes.
>
>
> You have a program (which you can not modify) that produces a list of
> files in columns on stdout, much like ls does (it does processing on
> the files to filter them according to some criteria). The columnar
> output retained even if stdout is not a terminal. You have a shell
> script which takes the output of the first command, and processes the
> resulting files in some way. You have no choice but to do it this
> way, because of some constraints being placed on you by management
> (e.g. using something else would require writing your own tool, and
> management doesn't want you to spend the time on it).
>
> The shell script can not reliably tell if the spaces are in the
> filenames, or if they are filename separators.
>
> I have also seen buggy ftp clients that did not allow spaces in
> filenames (it did not let you quote the arguments).
>
> In the real world, you will run into these kinds of problems... It
> does not matter that spaces are allowed in filenames; practical
> considerations may make them difficult or impossible to use.
>
> - --
> Derek D. Martin
> http://www.pizzashack.org/
> GPG Key ID: 0xDFBEAD02
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.7 (GNU/Linux)
>
> iD8DBQE+LYCCHEnASN++rQIRAkwYAJ950e4GJI79fI6Rx+ys2AXlI4K1zwCgv8a3
> 9k1CzfF7RpGBpxQCHGY+jpk=
> =DzqQ
> -----END PGP SIGNATURE-----
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
>
More information about the gnhlug-discuss
mailing list