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

Re: whence question



Nikolay Aleksandrovich Pavlov (ZyX) wrote on Sat, Jan 14, 2017 at 22:08:44 +0300:
> \*  E.g. when you issue `vim *.foo` you most likely do not want to
> open `*.foo` file if you happen to spell glob wrong or `tar cf foo.tar
> *.foo` will create empty archive if glob is spelled wrong and it
> received unexistent file as an argument.

Semantically, the glob «*.foo» and the literal filename «'*.foo'» would
be different types, if the shell language were strongly typed.  The
former would be a function that returns a list of words and the
latter would be (is) a word.

You could in principle define a pattern matching flavour where the
regexp /αλφα/ matches the plaintext «alfa», and then — let's assume for
the moment that all your filenames are ASCII — the commands
.
    % ls αλφα
    % ls alfa
.
would very clearly be different: one of them has a glob argument and one
of them has a literal string argument.

Now, the shell language is _not_ strongly typed, but nonetheless, when
people write «*.foo» intending a pattern that expands to one or more
filenames, it usually doesn't make sense to just use the pattern
instead — not any more than it would be logical for
.
    % echo αλφα > list-of-important-files.txt
.
to dump the Greek into the .txt file, in the example where all filenames
were ASCII.

Cheers,

Daniel



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