Skip to content

Bad checking of the --pattern argument #3982

@elibarzilay

Description

@elibarzilay

First of all, the --pattern argument description is giving very little
information: "used for files globbing"?? I had to try it out to see
how it's used.

Second, the way that it's implemented is probably going to be surprising
for most people. I'm guessing that almost everyone would expect a
pattern like x* to match all files that begin with x, but it looks
like the pattern is actually matched against the full path that is
copied, and therefore a pattern like x* will either copy a whole
toplevel directory that starts with x or nothing at all if there is
none.

Related to this, it should be clear exactly what gets matched. In an
attempt to avoid bogus matches in a list that iterates over a list of
globs, I prepended */ to each one (yes, that was a mistake) which
resulted in skipping a toplevel index.html file, and this is
regardless of specifying a full path as my --source or cding into
the directory and using a --source .. So I'm guessing that this
pattern is matched against the full path without the prefix --source
directory (which is the same as the full container + / + blob name
without the part that is specified in --destination). Summarizing
this in a short CLI description is going to be difficult, but it is
very needed.

Yet another bit that must be documented is the fact that * matches
any character, including /. It would have been much better to
have * not match /s, and instead add a ** pattern for that.

Given that there are probably scripts that rely on this behavior of
--pattern (at least the script that I wrote does so), a way to resolve
this would be to add some new --file-pattern that gets matched only
against the basename of files, and not against any directories. Maybe
also another --path-pattern flag with * not matching /s, and **
that does.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions