Unable to refresh

Ralph Corderoy ralph at inputplus.co.uk
Sat Mar 24 02:43:44 PDT 2018


Hi Richard,

> > > > If you are typing `get_player .* --since 70' into a Linux shell
>
> I have come across this in relation to bash "The characters *, ? and [
> are called glob characters or wild card characters. If an unquoted
> argument contains one or more glob characters, the shell processes the
> argument for file name generation.  The glob characters are part of
> glob patterns which represent file and directory names. These patterns
> are similar to regular expressions, but differ in syntax, since they
> are intended to match file names and words (not arbitrary strings).
> The special constructions that may appear in glob patterns are: ... "
>
> What that seems to mean is that without quotes around *. a file name
> or word can be matched by bash and with quotes an arbitrary string can
> be matched as a regex.  It is not clear to me why that matters.

The shell is expanding globs before invoking get_iplayer, thus they're
not seen by get_iplayer if they match anything.  If they don't match
anything then they normally remain and are passed to get_iplayer anyway.
For the arguments get_iplayer does see, it decides to interpret some of
them as regexps.

«get_iplayer Railway» has no glob metacharacters to expand so one
argument is passed to get_iplayer, it uses it as a regexp, it has no
regexp metacharacters so effectively is a substring search of the
titles.

«get_iplayer R.*way» has a glob metacharacter, the «*», the shell looks
at the current directory for entries starting «R.» and ending «way».
There are none.  The glob remains, unexpanded.  get_iplayer has one
argument, «R.*way» that it uses as a regexp.  There's two regexp
metacharacters, «.*», meaning zero or more of any character, used in the
search.

«get_iplayer R.*way» is run again, and again has a glob, the «*».  This
time, the current directory has «R.steinway» in it.  The argument with
the glob is expanded into that and get_iplayer has one argument,
«R.steinway», that's used as a regexp.  It's unlikely to match any
titles, e.g. «Resteinway».

To avoid glob expansion, quote the glob metacharacters, «get_iplayer
'R.*way'», and get_iplayer sees the regexp «R.*way».

> One thing that does not appear to have happened is infinite recursion,
> or even matching of additional programmes.

Your unquoted «.*» on Linux would often expand to «. ..», and perhaps
more if you've other `dot' files present.  These are two regexps
interpreted by get_iplayer.  It prints titles matching either.  Since
anything matching the second is also matched by the first, you are
seeing any title at least one character long.  That's almost like «.*»
and «^» except that a zero-length title won't be matched.

> As for using a single quote ' as the strongest quote, I suspect the
> documentation has used double quotes " for compatibility with Windows.

Yes, I expect you're right.  Fortunately, I've only had a little
exposure to that in the days of DOS.  :-)  If Windows doesn't treat «^»
specially then that could be used instead with no quoting needed.

-- 
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy



More information about the get_iplayer mailing list