Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Inconsistency of GLOB_ASSIGN
On Nov 27, 8:43pm, Peter Stephenson wrote:
} Subject: Re: Inconsistency of GLOB_ASSIGN
}
} It would be neater always to do an array assignment, in fact, but
} the traditional behaviour is that if there was only one result the
} assignment is scalar, and GLOB_ASSIGN is really there only for
} tradition.
That's too bad, because making it always be an array assignment is a
lot simpler than figuring out whether the glob expanded to something.
(I think. Still pondering.)
There are also very few contexts where a single-element array and
a scalar behave differently. The only one I can think of would be
subscript slices, but if you're glob-assigning to a variable and then
expecting to be able to subscript it as a string, you're already in
pretty strange territory.
One interesting thing is what happens with NO_NOMATCH. A failed glob
still returns a single-element array in that case, whereas a string
containing no globbing characters is a scalar.
} Arguably we should look at the type of the destination and if it's
} numeric not do a glob at all. I'd be happy with that, since:
}
} integer x
} x=3*3
}
} probably doesn't mean "look for files beginning and ending in 3"
The "happy" behavior is already the case for NO_GLOB_ASSIGN, so I
think it's OK to ignore the type of the variable when the value is
asserted to be a glob.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author