[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to handle whitespace in filenames ???



On Wed, Dec 19, 2001 at 09:46:41PM -0800, Erik Steffl wrote:
> ...
> 
>   let's note that it's mostly the shell, basically all other tools
> handle any characters properly (not talking about shell scripts, those
> all depend on how careful the author was).

The only reason the shell is special in this regard is that it's
the middleman in the user-application transaction.  It's parsing
the user's input into neat packets based on conventions and clues,
one of which is that whitespace delimits stuff.  If the shell were
to auto-quote, say, filenames with spaces, then I suspect that
special treatment would be lost if the shell was part of a pipeline
of commands.  The receiving application typically doesn't want
to deal with quote characters, after all, and those are handily,
simply, and thankfully removed by the shell.

In HTML they defined a space-looking character (sequence) to fix this
sort of problem, but that'd be hell for every shelled application to
have to deal with.  So then maybe the last shell process in a pipe
unspecializes the special space...  sounds ugly to me. (I've always
figured the underscore was that special space-looking character,
and it works quite nicely as it is.)

>   so we are not talking about how unix handles space in filenames but
> how shell handles space in its variables, that's really the main
> discussion (filename are influenced by that, but so are any other
> strings).

But the instigating case was of filenames arriving from backtics
enclosing a find command, so I don't see how variables apply here.
find conveniently presents its output with each filename on a
separate line; the backtics screw that up, as I suppose does xargs,
by glomming them all on a line delimited by spaces.  I think the
appropriate answer is "don't do that", and not "fix the shell",
but that's just my opinion.

Ken

-- 
Ken Irving <jkirving@mosquitonet.com>



Reply to: