Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't '*' work as a perl regexp in my .Rbuildignore file?

Tags:

r

perl

When I try to build a package with the following in my .Rbuildignore file,

*pdf                                                                            
*Rdata  

I get the errors:

Warning in readLines(ignore_file) : incomplete final line found on '/home/user/project/.Rbuildignore'

and

invalid regular expression '*pdf'

I thought '*' was a wildcard for one or more characters?

like image 373
David LeBauer Avatar asked Nov 27 '22 07:11

David LeBauer


2 Answers

There are two styles of pattern matching for files:

  1. regular expressions. These are used for general string pattern matching. See ?regex
  2. globs. These are typically used by UNIX shells. See ?Sys.glob

You seem to be thinking in terms of globs but .Rbuildignore uses regular expressions. To convert a glob to a regular expression try

> glob2rx("*pdf")
[1] "^.*pdf$"
like image 163
G. Grothendieck Avatar answered Dec 06 '22 12:12

G. Grothendieck


See help(regex) for help on regular expression, esp. the Perl variant, and try

 .*pdf
 .*Rdata

instead. The 'dot' matches any chartacter, and the 'star' says that it can repeat zero or more times. I just tried it on a package of mine and this did successfully ignore a pdf vignette as we asked it to.

like image 38
Dirk Eddelbuettel Avatar answered Dec 06 '22 13:12

Dirk Eddelbuettel