Subject: Re: fix for pd-ksh globbing
To: Simon J. Gerraty <sjg@crufty.net>
From: Greg A. Woods <woods@weird.com>
List: tech-userlevel
Date: 01/25/2002 15:36:15
[ On Friday, January 25, 2002 at 11:40:32 (-0800), Simon J. Gerraty wrote: ]
> Subject: Re: fix for pd-ksh globbing
>
> Since '#' is a comment char to the shell, I always use ./#* to avoid
> problems.

Yes, that's another way to prevent a '#' from being seen as the
beginning of a comment.  For the benefit of other readers I'll mention
that the manual says:

	#, if used at the beginning of a word, introduces a comment --
	everything after the # up to the nearest newline is ignored;

and earlier it defines a 'word' as:

	sequences of characters, are delimited by unquoted white-space
	characters (space, tab and newline) or meta-characters (<, >, |,
	;, &, ( and )).

Personally I like wording of the definitions given in "The Kornshell"
book better (though the ordering of the statements could be improved as
I show in this paraphrased quote):

	A comments may begin anywhere that a token may begin.  Comments
	are started with an unquoted '#' character and continue to the
	end of the current line.

> That's what should happen, yes.  I didn't specifically setout to fix
> that case, but its not surprising that it now works.

That was actually the feature I found most lacking.  I was quite happy
to expand a filename with spaces, either inside an already quoted string
if I knew ahead that it needed to be quoted, or

> Thanks for the input.  I can't promise I'll fix anything further - it
> took a number of years of daily anoyance to get around to fixing this
> one ;-)  but you never know.

I understand!  :-)

It would be nice to fix the elided backslash problem in particular, and
perhaps that is not too difficult, at least so it appears on first glance.

It would be ideal to fix the quoting of single-quote characters so that
expansions within already single-quoted strings would work properly
too.  ("A single-quote cannot occur within single-quotes.  A backslash
cannot be used to escape a single-quote in a single-quoted string.")
However fixing this requires detecting that the expanded word is in a
single-quoted string, wich may not be so simple, at least not to do
completely correctly.

If/when I get time I will look at this too.

> BTW Michael says the fix should be in the next release of pdksh.

Good to hear!

-- 
								Greg A. Woods

+1 416 218-0098;  <gwoods@acm.org>;  <g.a.woods@ieee.org>;  <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>