% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/thisfile.R
\name{thisfile}
\alias{thisfile}
\alias{thisfile_source}
\alias{thisfile_r}
\alias{thisfile_rscript}
\alias{thisfile_knit}
\title{Determines the path of the currently running script}
\usage{
thisfile()

thisfile_source()

thisfile_r()

thisfile_rscript()

thisfile_knit()
}
\value{
The path of the currently running script, NULL if it cannot be
determined.
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#soft-deprecated}{\figure{lifecycle-soft-deprecated.svg}{options: alt='[Soft-deprecated]'}}}{\strong{[Soft-deprecated]}}

\R does not store nor export the path of the currently running
script.  This is an attempt to circumvent this limitation by applying
heuristics (such as call stack and argument inspection) that work in many
cases.
\strong{CAVEAT}: Use this function only if your workflow does not permit other
solution: if a script needs to know its location, it should be set outside
the context of the script if possible.
}
\details{
This functions currently work only if the script was \code{source}d,
processed with \code{knitr},
or run with \code{Rscript} or using the \code{--file} parameter to the
\code{R} executable.  For code run with \code{Rscript}, the exact value
of the parameter passed to \code{Rscript} is returned.
}
\section{Life cycle}{


These functions are now available in the \pkg{whereami} package.
}

\examples{
\dontrun{
thisfile()
}
}
\references{
\url{https://stackoverflow.com/q/1815606/946850}
}
\seealso{
\code{\link[base:source]{base::source()}}, \code{\link[utils:Rscript]{utils::Rscript()}}, \code{\link[base:getwd]{base::getwd()}}
}
\author{
Kirill Müller, Hadley Wickham, Michael R. Head
}
\keyword{internal}
