Skip to content

Commit

Permalink
Quote all the paths to OPAMROOT when creating the init scripts on Unix
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Feb 15, 2024
1 parent e43b682 commit 505b01f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/state/opamEnv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -876,14 +876,18 @@ let source root shell f =
let fname = OpamFilename.to_string (OpamPath.init root // f) in
match shell with
| SH_csh ->
Printf.sprintf "if ( -f %s ) source %s >& /dev/null\n" fname fname
let fname = OpamStd.Env.escape_single_quotes fname in
Printf.sprintf "if ( -f '%s' ) source '%s' >& /dev/null\n" fname fname
| SH_fish ->
Printf.sprintf "source %s > /dev/null 2> /dev/null; or true\n" fname
let fname = OpamStd.Env.escape_single_quotes ~using_backslashes:true fname in
Printf.sprintf "source '%s' > /dev/null 2> /dev/null; or true\n" fname
| SH_sh | SH_bash ->
Printf.sprintf "test -r %s && . %s > /dev/null 2> /dev/null || true\n"
let fname = OpamStd.Env.escape_single_quotes fname in
Printf.sprintf "test -r '%s' && . '%s' > /dev/null 2> /dev/null || true\n"
fname fname
| SH_zsh ->
Printf.sprintf "[[ ! -r %s ]] || source %s > /dev/null 2> /dev/null\n"
let fname = OpamStd.Env.escape_single_quotes fname in
Printf.sprintf "[[ ! -r '%s' ]] || source '%s' > /dev/null 2> /dev/null\n"
fname fname
| SH_cmd ->
Printf.sprintf "if exist \"%s\" call \"%s\" >NUL 2>NUL\n" fname fname
Expand Down

0 comments on commit 505b01f

Please sign in to comment.