-
Notifications
You must be signed in to change notification settings - Fork 0
/
xx
59 lines (47 loc) · 1.84 KB
/
xx
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
if [ -n "$ZSH_VERSION" ]; then
___x_cmd_inner_cd(){
builtin cd "$@" || return;
};
else
___x_cmd_inner_cd(){
command cd "$@" || return;
};
fi;
___x_cmd_get_setupscript(){
___X_CMD_ROOT="${___X_CMD_ROOT:-"$HOME/.x-cmd.root"}";
command mkdir -p "$___X_CMD_ROOT/v";
___X_CMD_VERSION="${1:?Provide version}";
(
___x_cmd_inner_cd "$___X_CMD_ROOT/v";
if [ ! -d "$___X_CMD_VERSION" ]; then
command git clone -c core.autocrlf=false "${___X_CMD_GET_GITPROVIDER:-"[email protected]:"}x-cmd/$___X_CMD_VERSION.git";
else
printf "%s\n" "- I|x: Already exists: $PWD/$___X_CMD_VERSION" >&2;
___x_cmd_inner_cd "$___X_CMD_VERSION";
if [ "$(command git status -s | command wc -l)" -ne 0 ]; then
command git status -s;
command git stash;
command git clean -fd;
fi;
command git pull origin "$(command git branch --show-current)";
fi;
) || return 1;
(
___X_CMD_ROOT_CODE=;
___X_CMD_ROOT_MOD=;
___X_CMD_XRC_RELOAD=1;
___X_CMD_ADVISE_DISABLE=1;
. "$___X_CMD_ROOT/v/$___X_CMD_VERSION/X";
___x_cmd boot init;
);
if [ -n "$___X_CMD_XBINEXP_EXIT" ]; then
printf "%s\n" "- I|x: This installation/upgrade is performed by an external call, so the interactive shell for the new version will not automatically open." >&2;
elif [ -z "$___X_CMD_ROOT_MOD" ]; then
___X_CMD_ROOT_CODE=;
. "$___X_CMD_ROOT/v/$___X_CMD_VERSION/X";
elif [ "${-#*i}" != "$-" ]; then
printf "%s\n" "- I|x: x-cmd detected in current shell env. Opening a new shell to avoid collision." >&2;
___X_CMD_ROOT_CODE= ___X_CMD_ROOT="$___X_CMD_ROOT" ___X_CMD_VERSION="$___X_CMD_VERSION" "${SHELL:-/bin/sh}";
fi;
};
___x_cmd_get_setupscript "${XX:-x2}";