package core

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file core_sys.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
open! Import
include Base.Sys

let unix_quote x =
  if (not (String.is_empty x))
  && String.for_all x ~f:(function
       | 'a' .. 'z'
       | 'A' .. 'Z'
       | '0' .. '9'
       | '_' | '-' | ':' | '.' | '/' | ',' | '+' | '=' | '%' | '@' -> true
       | _ -> false)
  then (
    (* Shell keywords, as output by [compgen -k] for bash, [man dash] for dash, and [PATH=
       type -m '*' | grep reserved] for zsh, except for keywords that have special
       characters like [[. Note that builtins don't matter because 'alias' and alias
       behave the same, unlike 'if' and if. *)
    match x with
    | "if"
    | "then"
    | "else"
    | "elif"
    | "fi"
    | "case"
    | "esac"
    | "for"
    | "select"
    | "while"
    | "until"
    | "do"
    | "done"
    | "in"
    | "function"
    | "time"
    | "coproc"
    | "foreach"
    | "repeat"
    | "nocorrect" -> Filename.quote x
    | _ -> x)
  else Filename.quote x
;;

let quote =
  match Stdlib.Sys.os_type with
  | "Unix" -> unix_quote
  | _ -> Filename.quote
;;

let concat_quoted split_command =
  List.map ~f:quote split_command |> String.concat ~sep:" "
;;

let c_int_size = `Use_Sys_unix
let catch_break = `Use_Sys_unix
let chdir = `Use_Sys_unix
let command = `Use_Sys_unix
let command_exn = `Use_Sys_unix
let executable_name = `Use_Sys_unix
let execution_mode = `Use_Sys_unix
let file_exists = `Use_Sys_unix
let file_exists_exn = `Use_Sys_unix
let fold_dir = `Use_Sys_unix
let getcwd = `Use_Sys_unix
let home_directory = `Use_Sys_unix
let is_directory = `Use_Sys_unix
let is_directory_exn = `Use_Sys_unix
let is_file = `Use_Sys_unix
let is_file_exn = `Use_Sys_unix
let ls_dir = `Use_Sys_unix
let override_argv = `Use_Sys_unix
let readdir = `Use_Sys_unix
let remove = `Use_Sys_unix
let rename = `Use_Sys_unix
let unsafe_getenv = `Use_Sys_unix
let unsafe_getenv_exn = `Use_Sys_unix

exception Break = Stdlib.Sys.Break

module Private = struct
  let unix_quote = unix_quote
end
OCaml

Innovation. Community. Security.