shFILE {this.path}R Documentation

Get Argument FILE Provided to R by a Shell

Description

Look through the command line arguments, extracting FILE from either of the following: --file=FILE or -f FILE

Usage

shFILE(default, else.)
normalized.shFILE(default, else.)

Arguments

default

if FILE was not found, this value is returned.

else.

missing or a function to call on the return value if FILE is found. See tryCatch2 for inspiration.

Value

character string, or default if the command line argument FILE was not found.

Note

Both functions will save their return values; this makes them faster when called subsequent times.

For normalized.shFILE, the path on Windows will use / as the file separator.

See Also

this.path, here

Examples

this.path:::write.code(file = FILE <- tempfile(), {

    withAutoprint({

        shFILE()
        normalized.shFILE()
        normalized.shFILE(default = {
            stop("interestingly enough, because 'FILE' will be found,\n",
                "  argument 'default' won't be evaluated, and so this\n",
                "  error won't actually print, isn't that neat? you can\n",
                "  use this to your advantage in a similar manner, doing\n",
                "  arbitrary things only if 'FILE' isn't found")
        })


    }, width.cutoff = 60L, verbose = FALSE)

})
this.path:::.Rscript(c("--default-packages=this.path", "--vanilla", FILE))


for (expr in c("shFILE()",
               "shFILE(default = NULL)",
               "normalized.shFILE()",
               "normalized.shFILE(default = NULL)"))
    this.path:::.Rscript(c("--default-packages=this.path", "--vanilla", "-e", expr))

[Package this.path version 0.11.0 Index]