On Sun, Dec 28, 2014 at 04:45:34PM -0500, Karl Dahlke wrote:
> After some playing around with wordexp, I'm inclined to leave things alone.
> wordexp just does too much.
It certainly does a lot, but the existing code also does a fair amount,
and will still break on file names if they're not correctly escaped (which your
examples aren't). Also, I had to read the code to tell me how to
escape the meta characters (though I admit I may've just missed that one in the
user's guide).
I'm certainly thinking that glob would be a worth while change to make here,
possibly keeping the hand-rolled env variable expansion?
On the subject of that, what happens if I have the following:
testfile=mytest
and the file:
mytest_22.txt
and try:
r $testfile_22.txt
This doesn't work as testfile_22 is not a variable,
and there appears to be no current way to stop expansion (note that we can't
ignore env vars with _ in them as they're legal in posix shell).
Basically what I'm getting at here is that at the moment the code is buggy and
at least if we use wordexp we can say that "your file names must be valid in a
posix shell" or words to that effect and then it becomes fairly clear what's
allowed (simply \ escape anything you're not sure about).
Thus the above example becomes:
r ${testfile}_22.txt
and a file name like:
it'd be unfortunate to get this.txt
becomes:
it\'d\ be\ unfortunate\ to\ get\ this.txt
or:
"it'd be unfortunate to get this.txt"At the very least we should bring our variable expansion and escape character in line with something vaguely standard (i.e. optional braces for ambiguous cases in env variables and \ rather than `) imho. We should also probably use glob for... well... globbing I think. I'm also not confident there aren't more bugs there if someone pokes it hard enough. Having said all that, it'd probably be a nice idea to have a toggle command to switch off file name expansion for when you really don't need it and have some horrible file name to edit. Cheers, Adam.
signature.asc
Description: Digital signature
_______________________________________________ Edbrowse-dev mailing list [email protected] http://lists.the-brannons.com/mailman/listinfo/edbrowse-dev
