Module Oui.Sh_scriptSource

Sourcetype find_type =
  1. | Files
  2. | Dirs
Sourcetype numerical_op =
  1. | Gt
  2. | Lt
  3. | Eq
Sourcetype string_op =
  1. | Not_empty of string
  2. | Equal of string * string
Sourcetype condition =
  1. | Exists of string
  2. | Dir_exists of string
  3. | File_exists of string
  4. | Is_not_root
  5. | Writable_as_user of string
  6. | And of condition * condition
  7. | Not of condition
  8. | Num_op of string * numerical_op * int
  9. | Str_op of string_op
Sourcetype command =
  1. | Continue
  2. | Return of int
  3. | Exit of int
  4. | Echo of string
  5. | Print_err of string
  6. | Eval of string
  7. | Eval_inplace of command
  8. | Shift
  9. | Assign of {
    1. var : string;
    2. value : string;
    }
  10. | Assign_eval of {
    1. var : string;
    2. command : command;
    }
  11. | Dirname of string
  12. | Mkdir of {
    1. permissions : int option;
    2. dirs : string list;
    }
  13. | Chmod of {
    1. permissions : int;
    2. files : string list;
    }
  14. | Cp of {
    1. src : string;
    2. dst : string;
    }
  15. | Rm of {
    1. rec_ : bool;
    2. files : string list;
    }
  16. | Set_permissions_in of {
    1. on : find_type;
    2. permissions : int;
    3. starting_point : string;
    }
  17. | Copy_all_in of {
    1. src : string;
    2. dst : string;
    3. except : string;
    }
  18. | If of {
    1. condition : condition;
    2. then_ : command list;
    3. else_ : command list;
    }
  19. | Prompt of {
    1. question : string;
    2. varname : string;
    }
  20. | Case of {
    1. varname : string;
    2. cases : case list;
    }
  21. | While of {
    1. condition : condition;
    2. while_ : command list;
    }
  22. | Write_file of {
    1. file : string;
    2. lines : string list;
    3. append : bool;
    }
  23. | Read_file of {
    1. file : string;
    2. line_var : string;
    3. process_line : command list;
    }
  24. | Def_fun of {
    1. name : string;
    2. body : command list;
    }
  25. | Call_fun of {
    1. name : string;
    2. args : string list;
    }
Sourceand case = {
  1. pattern : string;
  2. commands : command list;
}
Sourcetype t = command list
Sourceval pp_sh : version:bool -> Format.formatter -> t -> unit

Prints the given script using shell syntax to the given formatter. If version is set to true, a comment containing oui version and commit hash is printed as a comment in scripts.

Sourceval continue : command
Sourceval return : int -> command

return i is "return i"

Sourceval exit : int -> command

exit i is "exit i"

Sourceval eval : string -> command

eval s is "eval \"s\""

Sourceval shift : command

shift is shift

Sourceval assign : var:string -> value:string -> command

assign ~var:"VAR" ~value:"value" is "VAR=\"value\""

Sourceval assign_eval : string -> command -> command

assign_eval var command is "VAR=\"$(command)\""

Sourceval dirname : string -> command

dirname path is "dirname \"path\""

Sourceval echof : ('a, Format.formatter, unit, command) format4 -> 'a

echo fmt args is "echo \"s\"" where s is the expanded format string.

Sourceval print_errf : ('a, Format.formatter, unit, command) format4 -> 'a

print_errf fmt args is "printf '%%s\\n' \"s\" >&2" where s is the expanded format string.

Sourceval mkdir : ?permissions:int -> string list -> command

mkdir f1::f2::_ is "mkdir -p f1 f2 ..."

Sourceval chmod : int -> string list -> command

chmod i f1::f2::_ is "chmod i f1 f2 ..."

Sourceval cp : src:string -> dst:string -> command

cp ~src ~dst is "cp src dst"

Sourceval rm : string list -> command

rm f1::f2::_ is "rm -f f1 f2 ..."

Sourceval rm_rf : string list -> command

rm_rf f1::f2::_ is "rm -rf f1 f2 ..."

symlink ~target ~link is "ln -s target link"

Sourceval if_ : condition -> command list -> ?else_:command list -> unit -> command

if_ condition commands is "if [ condition ]; then commands fi"

Sourceval set_permissions_in : on:find_type -> permissions:int -> string -> command

set_permissions_in starting_point ~on ~permissions is "find starting_point -type find_type -exec chmod permissions {} +"

Sourceval copy_all_in : src:string -> dst:string -> except:string -> command
Sourceval prompt : question:string -> varname:string -> command

promt ~question ~varname is "printf \"question \"" followed by read varname.

Sourceval case : string -> case list -> command
Sourceval while_ : condition -> command list -> command

while condition commands is "while [ condition ]; do commands done"

Sourceval write_file : ?append:bool -> string -> string list -> command

write_file file lines is "{ printf \"line1\n\"; printf \"line2\n\"; ... } > file". If append is set to true (default is false), append to file using ">>".

Sourceval read_file : line_var:string -> string -> command list -> command

read_file ~line_var file process_line is "while IFS= read -r line_var || [ -n $line_var]; do \ process_line \ done < file"

Sourceval def_fun : string -> command list -> command

def_fun name body is "name() { body }"

Sourceval call_fun : string -> string list -> command

call_fun name [arg1; arg2] is ["name arg1 arg2"]

Sourceval save : t -> OpamFilename.t -> unit