package opam-core

  1. Overview
  2. Docs

Querying

val tty_out : bool

true if stdout is bound to a terminal

val tty_in : bool

true if stdin is bound to a terminal

val terminal_columns : unit -> int

Queried lazily, but may change on SIGWINCH

val home : unit -> string

The user's home directory. Queried lazily

val etc : unit -> string

The /etc directory

type os =
  1. | Darwin
  2. | Linux
  3. | FreeBSD
  4. | OpenBSD
  5. | NetBSD
  6. | DragonFly
  7. | Cygwin
  8. | Win32
  9. | Unix
  10. | Other of string
val os : unit -> os

Queried lazily

val os_string : unit -> string
val arch : unit -> string

Queried lazily

val guess_shell_compat : unit -> [ `csh | `zsh | `sh | `bash | `fish ]

Guess the shell compat-mode

val guess_dot_profile : [ `csh | `zsh | `sh | `bash | `fish ] -> string

Guess the location of .profile

val path_sep : unit -> char

The separator character used in the PATH variable (varies depending on OS)

Exit handling

val at_exit : (unit -> unit) -> unit

Like Pervasives.at_exit but with the possibility to call manually (eg. before exec())

val exec_at_exit : unit -> unit

Calls the functions registered in at_exit. Unneeded if exiting normally

exception Exit of int

Indicates intention to exit the program with given exit code

exception Exec of string * string array * string array

Indicates intention to exec() the given command (paramters as per Unix.execvpe), after proper finalisations. It's the responsibility of the main function to catch this, call exec_at_exit, and Unix.execvpe.

val exit : int -> 'a

Raises Exit i

OCaml

Innovation. Community. Security.