R/os.R

Defines functions os.unix os.windows os.macos os.linux os

Documented in os os.linux os.macos os.unix os.windows

#' Operating System
#'
#' 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}, \code{os.unix}, and \code{os.windows}
#' return \code{TRUE} or \code{FALSE}.
#'
#' @note
#' The macOS operating system identifies itself as \code{"Darwin"}.
#'
#' Both Linux and macOS are \code{os.unix}.
#'
#' These shorthand functions can be useful when writing workaround solutions in
#' platform-independent scripts.
#'
#' @seealso
#' \code{\link{Sys.info}} is the underlying function used to extract the
#' operating system name.
#'
#' \code{\link{TAF-package}} gives an overview of the package.
#'
#' @examples
#' \donttest{
#' os()
#' os.linux()
#' os.macos()
#' os.unix()
#' os.windows()
#' }
#'
#' @export

os <- function()
{
  Sys.info()[["sysname"]]
}

#' @rdname os
#'
#' @export

os.linux <- function()
{
  os() == "Linux"
}

#' @rdname os
#'
#' @export

os.macos <- function()
{
  os() == "Darwin"
}

#' @rdname os
#'
#' @export

os.windows <- function()
{
  os() == "Windows"
}

#' @rdname os
#'
#' @export

os.unix <- function()
{
  os.linux() || os.macos()
}

Try the TAF package in your browser

Any scripts or data that you put into this service are public.

TAF documentation built on March 31, 2023, 6:51 p.m.