Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Globbing inside conditional expression



Hi,

Just come across this behaviour of globbing inside a conditional
expressions:

    % mkdir test
    % cd test
    % echo hello > foo.1
    % echo foo.*
    foo.1
    % [[ -s foo.1 ]] && echo yes || echo no
    yes
    % [[ -s $(echo foo.*) ]] && echo yes || echo no
    yes

    #### The following one does not do what I was expecting:
    % [[ -s foo.* ]] && echo yes || echo no
    no

    % echo $ZSH_VERSION
    4.2.6
    % man zshall

    [...]
    CONDITIONAL EXPRESSIONS
           [...]

           -s file
                  true if file exists and has size greater than zero.

           [...]

           Normal shell expansion is performed on the file, string and
           pattern arguments, but the result of each expansion is
           constrained to be a single word, similar to the effect of
           double quotes.  [...]

(I tried with 4.2.7 and got the same results.)

I was expecting 'normal shell expansion' to include globbing, but am I
misunderstanding this?

Thanks for any suggestions,

Ben.



Messages sorted by: Reverse Date, Date, Thread, Author