Spaces in filenames (was: shell script question)

John Abreau jabr at abreau.net
Tue Jan 21 13:35:21 EST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Content-Type: text/plain; charset=us-ascii

Jason Stephenson <jason at sigio.com> writes:

> 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.

It's also legal to have double-quotes in a filename, and your solution 
fails on such files. The fact is, a filename on Unix cannot include 
a null-byte or a "/" character. The "/" is explicitly disallowed so 
it can be used as a directory separator. No other characters are 
disallowed, because the Unix philosophy recognizes that Simple == Robust 
and Complicated == Brittle; introducing gratuitous restrictions in the 
kernel would have been pointless and would just complicate the code 
unnecessarily.

To restate my analogy a little differently, the Rules of the Road are a 
subset of the Laws of Physics. It's possible to hop in your car when 
you're stinking drunk and drive around on the roads, the sidewalks, 
and your neighbors' front lawns. Just as it's possible for a filename 
on Unix to include any eight-bit value that's not 0x0 (null) or 0x2F 
("/").
But cars don't include a device to sense when you're drunk and 
automatically kill the engine, and the lack of such a device in a car 
does not mean the car is "broken". 


- --
John Abreau / Executive Director, Boston Linux & Unix
Email jabr at blu.org / WWW http://www.abreau.net / PGP-Key-ID 0xD5C7B5D9
PGP-Key-Fingerprint 72 FB 39 4F 3C 3B D6 5B E0 C8 5A 6E F1 2C BE 99


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Exmh version 2.5 07/13/2001

iQCVAwUBPi2S6VV9A5rVx7XZAQLZ0AQAiPwlwCFSYlnCu+RylxTGy0vOQkUmxkFS
513bqXmx5qDZQ9H8rWrZqo84/bME5yPU8yO2ZrVRMUS4b7quAGNdityNNEobzJgZ
9X2A0SkVSaOxS1UC6zATI6iRMsafcB7+16sxpYrVHoND9VQkU51cO2PvtlRuVUoA
hR1sWuKAksA=
=/vsb
-----END PGP SIGNATURE-----




More information about the gnhlug-discuss mailing list