-
Notifications
You must be signed in to change notification settings - Fork 371
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
init scripts: revert environment before settings new one, on session loading #5036
base: master
Are you sure you want to change the base?
Conversation
… revert it. Also some rework of writing scripts functions, factorise `if' statement writing, add precondition handling, etc.
Printf.sprintf "%s\n%s" | ||
(* XXX duplicated with variables.sh *) | ||
(iif "! ${?OPAM_SWITCH_PREFIX}" {|setenv OPAM_SWITCH_PREFIX ""|}) | ||
(iif {|"x$OPAM_SWITCH_PREFIX" != "x"|} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same than bash safeguard, needed?
(iif {|"x$OPAM_SWITCH_PREFIX" != "x"|} | ||
"eval `opam env --revert --shell=csh --readonly`") | ||
| SH_fish -> | ||
iif {|test -n "$OPAM_SWITCH_PREFIX"|} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nox
safeguard trick, is it needed?
pad icond ithen (ielse_expr ielse) pad | ||
| SH_zsh -> | ||
Printf.sprintf "%sif [[ %s ]]; then\n %s%s%sfi" | ||
pad icond ithen (ielse_expr ielse) pad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the bash / zsh distinction needed here ? I thought both syntaxes existed in both, with [[
allowing more specific built-ins. [
should behave the same for zsh as for bash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply because I took if expression from if_interactive_script
, and it set this sh/zsh difference
# Prefix of the current opam switch | ||
OPAM_SWITCH_PREFIX='${BASEDIR}/root/fake'; export OPAM_SWITCH_PREFIX; | ||
# Current opam switch man dir | ||
MANPATH="$MANPATH":'${BASEDIR}/root/fake/man'; export MANPATH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too bad, we can't keep man in test, it's not present on some os
### cat root/opam-init/variables.sh
# Prefix of the current opam switch
OPAM_SWITCH_PREFIX='${BASEDIR}/root/fake'; export OPAM_SWITCH_PREFIX;
-# Current opam switch man dir
-MANPATH="$MANPATH":'${BASEDIR}/root/fake/man'; export MANPATH;
# Binary dir for opam switch fake
PATH='${BASEDIR}/root/fake/bin':"$PATH"; export PATH;
fix #4649 + add a test that display init scripts