in reply to Bizarre usage of <>

@foo is created with 8 elements, the 6th being "B and the 7th is C". @foo interpolated (which happens in the glob operator) gives 'a b c d A "B C" D'. So, if you give that to the shell to expand, you give it a string that parses to seven arguments. None of the arguments contain anything wildcards or other things for the shell to expand, so you get back the same seven arguments, the 6th one being B C (the quotes have been eaten when the shell parsed the string into arguments).

Abigail

Replies are listed 'Best First'.
Re: Re: Bizarre usage of <>
by nevyn (Monk) on Nov 06, 2003 at 12:23 UTC
    @foo interpolated (which happens in the glob operator)

    But glob() can't take an array, AFAIK. It just takes a single expression. For instance glob(@foo) turns the @foo into "8", just as doing glob(scalar(@foo)).

    So is the above a known extension to glob() when using <> (everything I'd seen just talked about <> being a shortcut, not having extra features).

    Even 5.8.0's File::Glob doesn't mention anything about being able to do shell argument expansion. And passing the list to bsd_glob() just takes the first argument. It's almost like it is doing a (join " ", @foo) somewhere.

    --
    James Antill
      But the glob function isn't used here. It's all about the glob operator. The fish hooks are quoting constructs, just like double quotes or slashes. And hence, variables, be them scalars or arrays get interpolated.

      It's like doing glob "@foo".

      Abigail

        Ahh, I see, the fish hooks are implicitly converting the argument to a string. Ie. changing $" changes what happens. Thanks.

        --
        James Antill