R Under development (unstable) (2024-07-28 r86931 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > message("*** current_script() ...") *** current_script() ... > > res <- startup::current_script() > print(res) [1] NA > stopifnot(is.character(res), length(res) == 1L, is.na(res)) > > startup:::current_script_pathname("foo") [1] "foo" > res <- startup::current_script() > print(res) [1] "foo" > stopifnot(is.character(res), length(res) == 1L, res == "foo") > > startup:::current_script_pathname(NA_character_) [1] NA > res <- startup::current_script() > print(res) [1] NA > stopifnot(is.character(res), length(res) == 1L, is.na(res)) > > message("*** current_script() ... DONE") *** current_script() ... DONE > > proc.time() user system elapsed 0.09 0.07 0.15