package opam-core

  1. Overview
  2. Docs

Module OpamStd.SysSource

Querying

Sourceval tty_out : bool

true if stdout is bound to a terminal

Sourceval tty_in : bool

true if stdin is bound to a terminal

Sourceval terminal_columns : unit -> int

Queried lazily, but may change on SIGWINCH

Sourceval home : unit -> string

The user's home directory. Queried lazily

Sourceval etc : unit -> string

The /etc directory

Sourceval system : unit -> string

The system directory (Windows only)

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

Queried lazily

Sourceval uname : string -> string option

The output of the command "uname", with the given argument. Memoised.

Sourceval executable_name : string -> string

Append .exe (only if missing) to executable filenames on Windows

Sourcetype shell =
  1. | SH_sh
  2. | SH_bash
  3. | SH_zsh
  4. | SH_csh
  5. | SH_fish

The different families of shells we know about

Sourceval guess_shell_compat : unit -> shell

Guess the shell compat-mode

Sourceval guess_dot_profile : shell -> string

Guess the location of .profile

Sourceval path_sep : char

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

Sourceval split_path_variable : ?clean:bool -> string -> string list

Splits a PATH-like variable separated with path_sep. More involved than it seems, because there may be quoting on Windows. By default, it returns the path cleaned (remove trailing, leading, contiguous delimiters). Optional argument clean permits to keep those empty strings.

Sourceval is_cygwin_variant : string -> [ `Native | `Cygwin | `CygLinked ]

For native Windows builds, returns `Cygwin if the command is a Cygwin- compiled executable, `CygLinked if the command links to a library which is itself Cygwin-compiled or `Native otherwise.

Note that this returns `Native on a Cygwin-build of opam!

Both cygcheck and an unqualified command will be resolved using the current PATH.

Exit handling

Sourceval at_exit : (unit -> unit) -> unit

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

Sourceval exec_at_exit : unit -> unit

Calls the functions registered in at_exit. Unneeded if exiting normally

Sourceexception Exit of int

Indicates intention to exit the program with given exit code

Sourceexception Exec of string * string array * string array

Indicates intention to exec() the given command (parameters 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.

Raises Exit i

Sourcetype exit_reason = [
  1. | `Success
  2. | `False
  3. | `Bad_arguments
  4. | `Not_found
  5. | `Aborted
  6. | `Locked
  7. | `No_solution
  8. | `File_error
  9. | `Package_operation_error
  10. | `Sync_error
  11. | `Configuration_error
  12. | `Solver_failure
  13. | `Internal_error
  14. | `User_interrupt
]
Sourceval exit_codes : (exit_reason * int) list
Sourceval get_exit_code : exit_reason -> int
Sourceval exit_because : exit_reason -> 'a

Raises Exit, with the code associated to the exit reason

OCaml

Innovation. Community. Security.