Wireshark-users: Re: [Wireshark-users] Exporting objects with invalid default filenames
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 24 Oct 2007 10:36:29 -0700
Luis EG Ontanon wrote:

in *NIX filenames  with spaces  are particularly tedious... I
personally would forbid spaces in filenames en-toto as they tend to
make scripts fail...

Well, insufficiently-carefully-written scripts, anyway.

	$ echo a b > a\ b
	$ echo c d > c\ d
	$ find . -type f -print0 | xargs -0 grep a /dev/null
	./a b:a b

I don't know whether all systems have the "-print0" flag to find (makes it terminate the file names it prints with a null byte rather than with a newline) and the "-0" flag to xargs (makes it expect file names terminated with a null byte), but that handles file names with spaces in them - and also handles a resulting file list bigger than the maximum number of arguments that can be passed in an exec call. (The /dev/null also makes sure there are at least two arguments to grep, so it always reports the file name.)

This is also a potential issue on Windows, if, for example, you're using a UN*X shell (I don't know whether you have to be careful when writing .bat files to make sure *they* handle file names with spaces in them).

Yes, file names with spaces are a bit more inconvenient to use from command lines (UN*X or Windows), but command-line support has gotten better over time (file name completion handles it in bash and the version of ksh in Leopard, at least, and options such as -print0 to find have shown up over time), and they aren't particularly inconvenient from a GUI. We might still want to, e.g. replace them with underscores, or have an option to allow them to be replaced with underscores.