Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fish unconditionally display manpath when fish version is 2.7 or later #3728

Merged
merged 3 commits into from
Mar 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/client/opamConfigCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ let rec print_fish_env env =
(OpamStd.Env.escape_single_quotes ~using_backslashes:true v))
v)
in
(* set manpath if and only if fish version >= 2.7 *)
let manpath_cmd v =
OpamConsole.msg "%s" (
(* test for existence of `argparse` builtin, introduced in fish 2.7 .
* use `grep' instead of `builtin string match' so that old fish versions do not
* produce unwanted error messages on stderr.
* use `grep' inside a `/bin/sh' fragment so that nothing is written to stdout or
* stderr if `grep' does not exist. *)
"builtin -n | /bin/sh -c 'grep -q \\'^argparse$\\'' 1>/dev/null 2>/dev/null; and "
) ;
set_arr_cmd "MANPATH" v in
match env with
| [] -> ()
| (k, v, _) :: r ->
Expand All @@ -185,8 +196,7 @@ let rec print_fish_env env =
* opamState.ml for details *)
set_arr_cmd k v
| "MANPATH" ->
if OpamStd.Env.getopt k <> None then
set_arr_cmd k v
manpath_cmd v
| _ ->
OpamConsole.msg "set -gx %s '%s';\n"
k (OpamStd.Env.escape_single_quotes ~using_backslashes:true v));
Expand Down