From de34b87307937206599b9b1ac255be996c897ad3 Mon Sep 17 00:00:00 2001 From: Arni Magnusson Date: Mon, 7 Jan 2019 11:05:48 +0100 Subject: [PATCH] New functions os(), os.macos() and os.linux() --- NAMESPACE | 3 +++ NEWS | 3 +++ R/icesTAF-package.R | 6 +++-- R/os.R | 52 +++++++++++++++++++++++++++++++++++------- man/icesTAF-package.Rd | 6 +++-- man/os.Rd | 47 ++++++++++++++++++++++++++++++++++++++ man/os.unix.Rd | 28 ----------------------- 7 files changed, 105 insertions(+), 40 deletions(-) create mode 100644 man/os.Rd delete mode 100644 man/os.unix.Rd diff --git a/NAMESPACE b/NAMESPACE index 33e738f..f483715 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,6 +16,9 @@ export(makeAll) export(makeTAF) export(mkdir) export(msg) +export(os) +export(os.linux) +export(os.macos) export(os.unix) export(os.windows) export(plus) diff --git a/NEWS b/NEWS index f5d422d..b7fd675 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ o Added function process.bib() to read and process metadata. o Added functions draft.data() and draft.software() to create initial draft versions of metadata files. +o Added functions os(), os.linux() and os.macos() to detect more operating + systems than before. Removed os.unix(). + o Updated colors (taf.green, taf.orange, taf.blue, taf.dark, taf.light) to make them equally intense and easy to distinguish. diff --git a/R/icesTAF-package.R b/R/icesTAF-package.R index 1d30d4a..378b7eb 100644 --- a/R/icesTAF-package.R +++ b/R/icesTAF-package.R @@ -76,8 +76,10 @@ #' \emph{Administrative tools:} #' \tabular{ll}{ #' \code{\link{deps}} \tab list dependencies\cr -#' \code{\link{os.unix}} \tab OS family\cr -#' \code{\link{os.windows}} \tab OS family +#' \code{\link{os}} \tab operating system\cr +#' \code{\link{os.linux}} \tab operating system\cr +#' \code{\link{os.macos}} \tab operating system\cr +#' \code{\link{os.windows}} \tab operating system #' } #' #' @author Arni Magnusson and Colin Millar. diff --git a/R/os.R b/R/os.R index ec013a7..7bdd5ee 100644 --- a/R/os.R +++ b/R/os.R @@ -1,32 +1,68 @@ -#' OS Family +#' Operating System #' -#' Determine whether operating system is Windows or Unix-compatible. +#' Determine operating system name. +#' +#' @return +#' \code{os} returns the name of the operating system, typically \code{"Linux"}, +#' \code{"Darwin"}, or \code{"Windows"}. +#' +#' \code{os.linux}, \code{os.macos}, and \code{os.windows} return \code{TRUE} or +#' \code{FALSE}. #' #' @note +#' The macOS operating system identifies itself as \code{"Darwin"}. +#' #' These shorthand functions can be useful when writing workaround solutions in #' platform-independent scripts. #' #' @seealso -#' \code{\link{.Platform}} reports the \code{OS.type} family. +#' \code{\link{Sys.info}} is the underlying function used to extract the +#' operating system name. #' #' \code{\link{icesTAF-package}} gives an overview of the package. #' #' @examples -#' os.unix() +#' os() +#' os.linux() +#' os.macos() #' os.windows() #' +#' @aliases os.unix +#' +#' @export + +os <- function() +{ + Sys.info()[["sysname"]] +} + +#' @rdname os +#' #' @export -os.unix <- function() +os.linux <- function() { - .Platform$OS.type == "unix" + os() == "Linux" } -#' @rdname os.unix +#' @rdname os +#' +#' @export + +os.macos <- function() +{ + os() == "Darwin" +} + +#' @rdname os #' #' @export os.windows <- function() { - .Platform$OS.type == "windows" + os() == "Windows" } + +#' @export + +os.unix <- os.linux diff --git a/man/icesTAF-package.Rd b/man/icesTAF-package.Rd index 11c869c..b8dda38 100644 --- a/man/icesTAF-package.Rd +++ b/man/icesTAF-package.Rd @@ -75,8 +75,10 @@ data, methods, and results used in ICES assessments. \emph{Administrative tools:} \tabular{ll}{ \code{\link{deps}} \tab list dependencies\cr - \code{\link{os.unix}} \tab OS family\cr - \code{\link{os.windows}} \tab OS family + \code{\link{os}} \tab operating system\cr + \code{\link{os.linux}} \tab operating system\cr + \code{\link{os.macos}} \tab operating system\cr + \code{\link{os.windows}} \tab operating system } } \references{ diff --git a/man/os.Rd b/man/os.Rd new file mode 100644 index 0000000..ed502fc --- /dev/null +++ b/man/os.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/os.R +\name{os} +\alias{os} +\alias{os.unix} +\alias{os.linux} +\alias{os.macos} +\alias{os.windows} +\title{Operating System} +\usage{ +os() + +os.linux() + +os.macos() + +os.windows() +} +\value{ +\code{os} returns the name of the operating system, typically \code{"Linux"}, +\code{"Darwin"}, or \code{"Windows"}. + +\code{os.linux}, \code{os.macos}, and \code{os.windows} return \code{TRUE} or +\code{FALSE}. +} +\description{ +Determine operating system name. +} +\note{ +The macOS operating system identifies itself as \code{"Darwin"}. + +These shorthand functions can be useful when writing workaround solutions in +platform-independent scripts. +} +\examples{ +os() +os.linux() +os.macos() +os.windows() + +} +\seealso{ +\code{\link{Sys.info}} is the underlying function used to extract the +operating system name. + +\code{\link{icesTAF-package}} gives an overview of the package. +} diff --git a/man/os.unix.Rd b/man/os.unix.Rd deleted file mode 100644 index e244cbd..0000000 --- a/man/os.unix.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/os.R -\name{os.unix} -\alias{os.unix} -\alias{os.windows} -\title{OS Family} -\usage{ -os.unix() - -os.windows() -} -\description{ -Determine whether operating system is Windows or Unix-compatible. -} -\note{ -These shorthand functions can be useful when writing workaround solutions in -platform-independent scripts. -} -\examples{ -os.unix() -os.windows() - -} -\seealso{ -\code{\link{.Platform}} reports the \code{OS.type} family. - -\code{\link{icesTAF-package}} gives an overview of the package. -}