valise-sh 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +152 -2
- package/README.md +99 -146
- package/bin/valise +57 -5376
- package/docs/architecture.md +77 -121
- package/docs/contrib-modules.md +172 -218
- package/docs/installation.md +137 -83
- package/docs/module-abi.md +125 -126
- package/docs/projects.md +249 -0
- package/docs/release-policy.md +68 -93
- package/docs/shared-modules.md +40 -39
- package/examples/README.md +12 -11
- package/examples/e2e/README.md +59 -66
- package/examples/e2e/bundles.tsv +6 -0
- package/examples/e2e/module.d/e2e_aliases.meta +1 -2
- package/examples/e2e/module.d/e2e_completions_bash.meta +0 -1
- package/examples/e2e/module.d/e2e_completions_zsh.meta +0 -1
- package/examples/e2e/module.d/e2e_env_setup.meta +2 -3
- package/examples/e2e/module.d/e2e_fish_features.meta +0 -1
- package/examples/e2e/module.d/e2e_generated_config.meta +1 -2
- package/examples/e2e/module.d/e2e_ksh_features.meta +0 -1
- package/examples/e2e/module.d/e2e_layer_probe.meta +1 -2
- package/examples/e2e/module.d/e2e_optional_network.meta +1 -2
- package/examples/e2e/module.d/e2e_platform_tools.meta +8 -0
- package/examples/e2e/module.d/e2e_platform_tools_bsd.meta +2 -3
- package/examples/e2e/module.d/e2e_platform_tools_darwin.meta +2 -3
- package/examples/e2e/module.d/e2e_platform_tools_linux.meta +2 -3
- package/examples/e2e/valise.conf +4 -0
- package/examples/e2e/variants.tsv +3 -0
- package/examples/local/module.d/hello_valise.meta +1 -2
- package/examples/profile-project/README.md +78 -108
- package/examples/profile-project/bundles.tsv +8 -0
- package/examples/profile-project/{shell/layers → layers}/demo/module.d/contrib_demo_greeting.meta +1 -2
- package/examples/profile-project/{shell/module.d → module.d}/greeting.meta +1 -2
- package/examples/profile-project/{shell/module.d → module.d}/profile_main.meta +0 -1
- package/examples/profile-project/{shell/modules → modules}/greeting.sh +1 -1
- package/examples/profile-project/valise.conf +4 -0
- package/examples/profile-project/variants.tsv +3 -0
- package/examples/shared/README.md +13 -34
- package/examples/shared/module.d/contrib_shared_paths.meta +2 -3
- package/examples/shared/module.d/contrib_shared_umask.meta +1 -2
- package/examples/shared/modules/shared/contrib_shared_paths.sh +2 -2
- package/lib/capabilities.sh +40 -13
- package/lib/cli/commands.sh +278 -0
- package/lib/cli/common.sh +326 -0
- package/lib/cli/devtools.sh +539 -0
- package/lib/cli/fish-hook.sh +986 -0
- package/lib/cli/integration.sh +337 -0
- package/lib/cli/lifecycle.sh +578 -0
- package/lib/cli/project.sh +1807 -0
- package/lib/cli/store.sh +1023 -0
- package/lib/cli/usage.sh +308 -0
- package/lib/compiler.awk +11 -4
- package/lib/fish/loader.fish +69 -9
- package/lib/fish/metadata.fish +49 -5
- package/lib/fish/profile.fish +170 -0
- package/lib/loader.sh +6 -8
- package/lib/metadata.sh +111 -5
- package/manifests/parser-support.tsv +2 -2
- package/module.d/valise_editor.meta +9 -0
- package/module.d/valise_history.meta +9 -0
- package/module.d/valise_pager.meta +9 -0
- package/module.d/valise_path.meta +9 -0
- package/module.d/{platform_bsd.meta → valise_platform_bsd.meta} +3 -4
- package/module.d/{platform_linux.meta → valise_platform_linux.meta} +3 -4
- package/module.d/{platform_macos.meta → valise_platform_macos.meta} +3 -4
- package/module.d/{platform_posix.meta → valise_platform_posix.meta} +2 -3
- package/module.d/valise_xdg.meta +9 -0
- package/modules/system/{contrib_editor.sh → valise_editor.sh} +2 -2
- package/modules/system/{contrib_history.sh → valise_history.sh} +2 -2
- package/modules/system/{contrib_pager.sh → valise_pager.sh} +2 -2
- package/modules/system/{contrib_path.sh → valise_path.sh} +3 -3
- package/modules/system/{contrib_xdg.sh → valise_xdg.sh} +2 -2
- package/package.json +91 -10
- package/docs/variants.md +0 -327
- package/entrypoints/.gitkeep +0 -0
- package/entrypoints/fish/profile.fish +0 -99
- package/examples/e2e/build-manifest.sh +0 -138
- package/examples/local/.gitkeep +0 -0
- package/examples/profile-project/shell/release/bundle-roots +0 -9
- package/examples/profile-project/shell/release/install-variants +0 -3
- package/examples/profile-project/shell/release/module-registry.tsv +0 -4
- package/examples/profile-project/shell/release/project.conf +0 -3
- package/lib/.gitkeep +0 -0
- package/manifests/.gitkeep +0 -0
- package/module.d/.gitkeep +0 -0
- package/module.d/contrib_editor.meta +0 -10
- package/module.d/contrib_history.meta +0 -10
- package/module.d/contrib_pager.meta +0 -10
- package/module.d/contrib_path.meta +0 -10
- package/module.d/contrib_xdg.meta +0 -10
- package/modules/.gitkeep +0 -0
- /package/examples/profile-project/{shell/layers → layers}/demo/modules/shared/contrib_demo_greeting.sh +0 -0
|
@@ -0,0 +1,986 @@
|
|
|
1
|
+
# Copyright (c) 2026 Joseph Cumines
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
# valise CLI: Fish startup hook generator.
|
|
4
|
+
# Sourced by bin/valise; not executable on its own.
|
|
5
|
+
|
|
6
|
+
print_fish_integration() {
|
|
7
|
+
_fish_active_literal=$(fish_quote "$VALISE_ACTIVE_LINK") || return 1
|
|
8
|
+
_fish_cli_dir=$(cd "$(path_parent "$_valise_cli_path")" 2>/dev/null && pwd -P) || return 1
|
|
9
|
+
_fish_cli_path="$_fish_cli_dir/${_valise_cli_path##*/}"
|
|
10
|
+
_fish_cli_literal=$(fish_quote "$_fish_cli_path") || return 1
|
|
11
|
+
_fish_source_tree_mode=${_fish_source_tree_mode:-0}
|
|
12
|
+
printf '%s\n' \
|
|
13
|
+
"# valise Fish integration. Do not edit." \
|
|
14
|
+
"# This hook loads the active valise release for Fish sessions." \
|
|
15
|
+
"begin" \
|
|
16
|
+
"set -l _valise_fish_source_tree_mode $_fish_source_tree_mode" \
|
|
17
|
+
"set -l _valise_fish_previous_root ''" \
|
|
18
|
+
"if builtin set -q SHELL_PROJECT_ROOT; and builtin test (builtin count \$SHELL_PROJECT_ROOT) -eq 1" \
|
|
19
|
+
" set _valise_fish_previous_root (builtin path resolve -- \"\$SHELL_PROJECT_ROOT\" 2>/dev/null)" \
|
|
20
|
+
"end" \
|
|
21
|
+
"# Authenticate the universal-variable store before any untrusted release source runs." \
|
|
22
|
+
"set -l _valise_fish_persistence_config_home ''" \
|
|
23
|
+
"if builtin set -q XDG_CONFIG_HOME; and test -n \"\$XDG_CONFIG_HOME\"" \
|
|
24
|
+
" set _valise_fish_persistence_config_home \"\$XDG_CONFIG_HOME\"" \
|
|
25
|
+
"else if builtin set -q HOME; and test -n \"\$HOME\"" \
|
|
26
|
+
" set _valise_fish_persistence_config_home \"\$HOME/.config\"" \
|
|
27
|
+
"else" \
|
|
28
|
+
" builtin exit 125" \
|
|
29
|
+
"end" \
|
|
30
|
+
"set -l _valise_fish_persistence_durable_file \"\$_valise_fish_persistence_config_home/fish/fish_variables\"" \
|
|
31
|
+
"set -g _valise_fish_persistence_path_physical_helper __valise_fish_path_(builtin random)" \
|
|
32
|
+
"function \$_valise_fish_persistence_path_physical_helper --no-scope-shadowing" \
|
|
33
|
+
" set -l _persistence_path \$argv[1]" \
|
|
34
|
+
" if test -x /usr/bin/uname; and test (/usr/bin/uname -s 2>/dev/null) = Darwin" \
|
|
35
|
+
" if builtin test -L /var; and test (builtin path resolve -- /var 2>/dev/null) = /private/var" \
|
|
36
|
+
" switch \"\$_persistence_path\"" \
|
|
37
|
+
" case /var" \
|
|
38
|
+
" set _persistence_path /private/var" \
|
|
39
|
+
" case '/var/*'" \
|
|
40
|
+
" set _persistence_path (builtin string replace -r '^/var' /private/var -- \"\$_persistence_path\")" \
|
|
41
|
+
" end" \
|
|
42
|
+
" end" \
|
|
43
|
+
" if builtin test -L /tmp; and test (builtin path resolve -- /tmp 2>/dev/null) = /private/tmp" \
|
|
44
|
+
" switch \"\$_persistence_path\"" \
|
|
45
|
+
" case /tmp" \
|
|
46
|
+
" set _persistence_path /private/tmp" \
|
|
47
|
+
" case '/tmp/*'" \
|
|
48
|
+
" set _persistence_path (builtin string replace -r '^/tmp' /private/tmp -- \"\$_persistence_path\")" \
|
|
49
|
+
" end" \
|
|
50
|
+
" end" \
|
|
51
|
+
" end" \
|
|
52
|
+
" if not builtin string match -q '/*' -- \"\$_persistence_path\"; or builtin string match -q '*//*' -- \"\$_persistence_path\"" \
|
|
53
|
+
" return 1" \
|
|
54
|
+
" end" \
|
|
55
|
+
" set _persistence_prefix /" \
|
|
56
|
+
" for _persistence_component in (builtin string split '/' -- \"\$_persistence_path\")" \
|
|
57
|
+
" if test -z \"\$_persistence_component\"" \
|
|
58
|
+
" continue" \
|
|
59
|
+
" end" \
|
|
60
|
+
" switch \"\$_persistence_component\"" \
|
|
61
|
+
" case . .." \
|
|
62
|
+
" return 1" \
|
|
63
|
+
" end" \
|
|
64
|
+
" if test \"\$_persistence_prefix\" = /" \
|
|
65
|
+
" set _persistence_prefix /\$_persistence_component" \
|
|
66
|
+
" else" \
|
|
67
|
+
" set _persistence_prefix \"\$_persistence_prefix/\$_persistence_component\"" \
|
|
68
|
+
" end" \
|
|
69
|
+
" if builtin test -L \"\$_persistence_prefix\"" \
|
|
70
|
+
" return 1" \
|
|
71
|
+
" end" \
|
|
72
|
+
" end" \
|
|
73
|
+
" return 0" \
|
|
74
|
+
"end" \
|
|
75
|
+
"if not \$_valise_fish_persistence_path_physical_helper \"\$_valise_fish_persistence_durable_file\"" \
|
|
76
|
+
" builtin exit 125" \
|
|
77
|
+
"end" \
|
|
78
|
+
"# Capture an absolute, writable, searchable temp parent before untrusted source." \
|
|
79
|
+
"set -l _valise_fish_persistence_tmp_parent /tmp" \
|
|
80
|
+
"if builtin set -q TMPDIR; and test -n \"\$TMPDIR\"" \
|
|
81
|
+
" set _valise_fish_persistence_tmp_parent \"\$TMPDIR\"" \
|
|
82
|
+
"end" \
|
|
83
|
+
"set _valise_fish_persistence_tmp_parent (builtin path resolve -- \"\$_valise_fish_persistence_tmp_parent\" 2>/dev/null)" \
|
|
84
|
+
"if test (builtin count \$_valise_fish_persistence_tmp_parent) -ne 1; or not test -d \"\$_valise_fish_persistence_tmp_parent\"; or not test -w \"\$_valise_fish_persistence_tmp_parent\"; or not test -x \"\$_valise_fish_persistence_tmp_parent\"" \
|
|
85
|
+
" builtin exit 125" \
|
|
86
|
+
"end" \
|
|
87
|
+
"# Capture persistent SHELL_PROJECT_ROOT scopes before clearing activation state." \
|
|
88
|
+
"set -l _valise_fish_scratch_names _valise_fish_root_global_set _valise_fish_root_global_exported _valise_fish_root_global_values _valise_fish_root_universal_set _valise_fish_root_universal_exported _valise_fish_root_universal_values VALISE_MODULE_ROOT XDG_CONFIG_HOME TMPDIR HOME" \
|
|
89
|
+
"set -l _valise_fish_scratch_prefix __valise_fish_scratch_state_(builtin random)" \
|
|
90
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_set_global_present" \
|
|
91
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_set_global_exported" \
|
|
92
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_set_global_values" \
|
|
93
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_set_universal_present" \
|
|
94
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_set_universal_exported" \
|
|
95
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_set_universal_values" \
|
|
96
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_exported_global_present" \
|
|
97
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_exported_global_exported" \
|
|
98
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_exported_global_values" \
|
|
99
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_exported_universal_present" \
|
|
100
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_exported_universal_exported" \
|
|
101
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_exported_universal_values" \
|
|
102
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_values_global_present" \
|
|
103
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_values_global_exported" \
|
|
104
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_values_global_values" \
|
|
105
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_values_universal_present" \
|
|
106
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_values_universal_exported" \
|
|
107
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_global_values_universal_values" \
|
|
108
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_set_global_present" \
|
|
109
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_set_global_exported" \
|
|
110
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_set_global_values" \
|
|
111
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_set_universal_present" \
|
|
112
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_set_universal_exported" \
|
|
113
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_set_universal_values" \
|
|
114
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_exported_global_present" \
|
|
115
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_exported_global_exported" \
|
|
116
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_exported_global_values" \
|
|
117
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_exported_universal_present" \
|
|
118
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_exported_universal_exported" \
|
|
119
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_exported_universal_values" \
|
|
120
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_values_global_present" \
|
|
121
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_values_global_exported" \
|
|
122
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_values_global_values" \
|
|
123
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_values_universal_present" \
|
|
124
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_values_universal_exported" \
|
|
125
|
+
"set -l \"\$_valise_fish_scratch_prefix\"__valise_fish_root_universal_values_universal_values" \
|
|
126
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_VALISE_MODULE_ROOT_global_present" \
|
|
127
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_VALISE_MODULE_ROOT_global_exported" \
|
|
128
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_VALISE_MODULE_ROOT_global_values" \
|
|
129
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_VALISE_MODULE_ROOT_universal_present" \
|
|
130
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_VALISE_MODULE_ROOT_universal_exported" \
|
|
131
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_VALISE_MODULE_ROOT_universal_values" \
|
|
132
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_XDG_CONFIG_HOME_global_present" \
|
|
133
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_XDG_CONFIG_HOME_global_exported" \
|
|
134
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_XDG_CONFIG_HOME_global_values" \
|
|
135
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_XDG_CONFIG_HOME_universal_present" \
|
|
136
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_XDG_CONFIG_HOME_universal_exported" \
|
|
137
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_XDG_CONFIG_HOME_universal_values" \
|
|
138
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_TMPDIR_global_present" \
|
|
139
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_TMPDIR_global_exported" \
|
|
140
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_TMPDIR_global_values" \
|
|
141
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_TMPDIR_universal_present" \
|
|
142
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_TMPDIR_universal_exported" \
|
|
143
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_TMPDIR_universal_values" \
|
|
144
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_HOME_global_present" \
|
|
145
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_HOME_global_exported" \
|
|
146
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_HOME_global_values" \
|
|
147
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_HOME_universal_present" \
|
|
148
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_HOME_universal_exported" \
|
|
149
|
+
"set -l \"\$_valise_fish_scratch_prefix\"_HOME_universal_values" \
|
|
150
|
+
"set -l _valise_fish_scratch_capture_helper __valise_fish_scratch_capture_(builtin random)" \
|
|
151
|
+
"function \$_valise_fish_scratch_capture_helper --no-scope-shadowing" \
|
|
152
|
+
" set -l _scratch_target \$argv[1]" \
|
|
153
|
+
" set -l _scratch_prefix \$argv[2]_\$_scratch_target" \
|
|
154
|
+
" set -l _scratch_global_present 0" \
|
|
155
|
+
" builtin set -q -g \"\$_scratch_target\"; and set _scratch_global_present 1" \
|
|
156
|
+
" set -l _scratch_global_exported 0" \
|
|
157
|
+
" builtin set -q -gx \"\$_scratch_target\"; and set _scratch_global_exported 1" \
|
|
158
|
+
" set -l _scratch_global_values" \
|
|
159
|
+
" if test \$_scratch_global_present -eq 1" \
|
|
160
|
+
" set _scratch_global_values \$\$_scratch_target" \
|
|
161
|
+
" end" \
|
|
162
|
+
" set -l _scratch_universal_present 0" \
|
|
163
|
+
" builtin set -q -U \"\$_scratch_target\"; and set _scratch_universal_present 1" \
|
|
164
|
+
" set -l _scratch_universal_exported 0" \
|
|
165
|
+
" builtin set -q -Ux \"\$_scratch_target\"; and set _scratch_universal_exported 1" \
|
|
166
|
+
" set -l _scratch_universal_values" \
|
|
167
|
+
" if test \$_scratch_universal_present -eq 1" \
|
|
168
|
+
" if test \$_scratch_global_present -eq 1" \
|
|
169
|
+
" builtin set -e -g \"\$_scratch_target\"" \
|
|
170
|
+
" set _scratch_universal_values \$\$_scratch_target" \
|
|
171
|
+
" if test \$_scratch_global_exported -eq 1" \
|
|
172
|
+
" builtin set -gx \"\$_scratch_target\" \$\$_scratch_global_values" \
|
|
173
|
+
" else" \
|
|
174
|
+
" builtin set -g \"\$_scratch_target\" \$\$_scratch_global_values" \
|
|
175
|
+
" end" \
|
|
176
|
+
" else" \
|
|
177
|
+
" set _scratch_universal_values \$\$_scratch_target" \
|
|
178
|
+
" end" \
|
|
179
|
+
" end" \
|
|
180
|
+
" set \"\$_scratch_prefix\"_global_present \$_scratch_global_present" \
|
|
181
|
+
" set \"\$_scratch_prefix\"_global_exported \$_scratch_global_exported" \
|
|
182
|
+
" set \"\$_scratch_prefix\"_global_values \$_scratch_global_values" \
|
|
183
|
+
" set \"\$_scratch_prefix\"_universal_present \$_scratch_universal_present" \
|
|
184
|
+
" set \"\$_scratch_prefix\"_universal_exported \$_scratch_universal_exported" \
|
|
185
|
+
" set \"\$_scratch_prefix\"_universal_values \$_scratch_universal_values" \
|
|
186
|
+
"end" \
|
|
187
|
+
"\$_valise_fish_scratch_capture_helper _valise_fish_root_global_set \"\$_valise_fish_scratch_prefix\"" \
|
|
188
|
+
"\$_valise_fish_scratch_capture_helper _valise_fish_root_global_exported \"\$_valise_fish_scratch_prefix\"" \
|
|
189
|
+
"\$_valise_fish_scratch_capture_helper _valise_fish_root_global_values \"\$_valise_fish_scratch_prefix\"" \
|
|
190
|
+
"\$_valise_fish_scratch_capture_helper _valise_fish_root_universal_set \"\$_valise_fish_scratch_prefix\"" \
|
|
191
|
+
"\$_valise_fish_scratch_capture_helper _valise_fish_root_universal_exported \"\$_valise_fish_scratch_prefix\"" \
|
|
192
|
+
"\$_valise_fish_scratch_capture_helper _valise_fish_root_universal_values \"\$_valise_fish_scratch_prefix\"" \
|
|
193
|
+
"\$_valise_fish_scratch_capture_helper VALISE_MODULE_ROOT \"\$_valise_fish_scratch_prefix\"" \
|
|
194
|
+
"\$_valise_fish_scratch_capture_helper XDG_CONFIG_HOME \"\$_valise_fish_scratch_prefix\"" \
|
|
195
|
+
"\$_valise_fish_scratch_capture_helper TMPDIR \"\$_valise_fish_scratch_prefix\"" \
|
|
196
|
+
"\$_valise_fish_scratch_capture_helper HOME \"\$_valise_fish_scratch_prefix\"" \
|
|
197
|
+
"builtin functions -e \$_valise_fish_scratch_capture_helper 2>/dev/null" \
|
|
198
|
+
"set -l _valise_fish_root_global_set 0" \
|
|
199
|
+
"set -l _valise_fish_root_global_exported 0" \
|
|
200
|
+
"set -l _valise_fish_root_global_values" \
|
|
201
|
+
"set -l _valise_fish_root_universal_set 0" \
|
|
202
|
+
"set -l _valise_fish_root_universal_exported 0" \
|
|
203
|
+
"set -l _valise_fish_root_universal_values" \
|
|
204
|
+
"set -l _valise_fish_root_capture_helper __valise_fish_capture_(builtin random)" \
|
|
205
|
+
"function \$_valise_fish_root_capture_helper --no-scope-shadowing" \
|
|
206
|
+
" set _valise_fish_root_global_set 0" \
|
|
207
|
+
" set _valise_fish_root_global_exported 0" \
|
|
208
|
+
" set _valise_fish_root_global_values" \
|
|
209
|
+
" set _valise_fish_root_universal_set 0" \
|
|
210
|
+
" set _valise_fish_root_universal_exported 0" \
|
|
211
|
+
" set _valise_fish_root_universal_values" \
|
|
212
|
+
" if builtin set -q -g SHELL_PROJECT_ROOT" \
|
|
213
|
+
" set _valise_fish_root_global_set 1" \
|
|
214
|
+
" builtin set -q -gx SHELL_PROJECT_ROOT; and set _valise_fish_root_global_exported 1" \
|
|
215
|
+
" set _valise_fish_root_global_values \$SHELL_PROJECT_ROOT" \
|
|
216
|
+
" end" \
|
|
217
|
+
" if builtin set -q -U SHELL_PROJECT_ROOT" \
|
|
218
|
+
" set _valise_fish_root_universal_set 1" \
|
|
219
|
+
" builtin set -q -Ux SHELL_PROJECT_ROOT; and set _valise_fish_root_universal_exported 1" \
|
|
220
|
+
" if builtin test \$_valise_fish_root_global_set -eq 1" \
|
|
221
|
+
" builtin set -e -g SHELL_PROJECT_ROOT; or builtin exit 125" \
|
|
222
|
+
" set _valise_fish_root_universal_values \$SHELL_PROJECT_ROOT" \
|
|
223
|
+
" if builtin test \$_valise_fish_root_global_exported -eq 1" \
|
|
224
|
+
" builtin set -gx SHELL_PROJECT_ROOT \$_valise_fish_root_global_values; or builtin exit 125" \
|
|
225
|
+
" else" \
|
|
226
|
+
" builtin set -g SHELL_PROJECT_ROOT \$_valise_fish_root_global_values; or builtin exit 125" \
|
|
227
|
+
" end" \
|
|
228
|
+
" else" \
|
|
229
|
+
" set _valise_fish_root_universal_values \$SHELL_PROJECT_ROOT" \
|
|
230
|
+
" end" \
|
|
231
|
+
" end" \
|
|
232
|
+
"end" \
|
|
233
|
+
"\$_valise_fish_root_capture_helper" \
|
|
234
|
+
"builtin functions -e \$_valise_fish_root_capture_helper" \
|
|
235
|
+
"set -l _valise_fish_scratch_restore_helper __valise_fish_scratch_restore_(builtin random)" \
|
|
236
|
+
"function \$_valise_fish_scratch_restore_helper --no-scope-shadowing" \
|
|
237
|
+
" set -l _scratch_target \$argv[1]" \
|
|
238
|
+
" set -l _scratch_prefix \$argv[2]_\$_scratch_target" \
|
|
239
|
+
" set -l _scratch_global_present_var \"\$_scratch_prefix\"_global_present" \
|
|
240
|
+
" set -l _scratch_global_exported_var \"\$_scratch_prefix\"_global_exported" \
|
|
241
|
+
" set -l _scratch_global_values_var \"\$_scratch_prefix\"_global_values" \
|
|
242
|
+
" set -l _scratch_universal_present_var \"\$_scratch_prefix\"_universal_present" \
|
|
243
|
+
" set -l _scratch_universal_exported_var \"\$_scratch_prefix\"_universal_exported" \
|
|
244
|
+
" set -l _scratch_universal_values_var \"\$_scratch_prefix\"_universal_values" \
|
|
245
|
+
" if builtin set -q -g \"\$_scratch_target\"" \
|
|
246
|
+
" builtin set -e -g \"\$_scratch_target\"; or return 125" \
|
|
247
|
+
" end" \
|
|
248
|
+
" if builtin set -q -U \"\$_scratch_target\"" \
|
|
249
|
+
" builtin set -e -U \"\$_scratch_target\"; or return 125" \
|
|
250
|
+
" end" \
|
|
251
|
+
" if test \$\$_scratch_global_present_var -eq 1" \
|
|
252
|
+
" set -l _scratch_global_flags -g" \
|
|
253
|
+
" if test \$\$_scratch_global_exported_var -eq 1" \
|
|
254
|
+
" set _scratch_global_flags -gx" \
|
|
255
|
+
" end" \
|
|
256
|
+
" builtin set \$_scratch_global_flags \"\$_scratch_target\" \$\$_scratch_global_values_var" \
|
|
257
|
+
" if test \$status -ne 0" \
|
|
258
|
+
" return 125" \
|
|
259
|
+
" end" \
|
|
260
|
+
" end" \
|
|
261
|
+
" if test \$\$_scratch_universal_present_var -eq 1" \
|
|
262
|
+
" set -l _scratch_universal_flags -U" \
|
|
263
|
+
" if test \$\$_scratch_universal_exported_var -eq 1" \
|
|
264
|
+
" set _scratch_universal_flags -Ux" \
|
|
265
|
+
" end" \
|
|
266
|
+
" builtin set \$_scratch_universal_flags \"\$_scratch_target\" \$\$_scratch_universal_values_var" \
|
|
267
|
+
" if test \$status -ne 0" \
|
|
268
|
+
" return 125" \
|
|
269
|
+
" end" \
|
|
270
|
+
" end" \
|
|
271
|
+
" if test \"\$_scratch_target\" = VALISE_MODULE_ROOT; or test \"\$_scratch_target\" = XDG_CONFIG_HOME; or test \"\$_scratch_target\" = TMPDIR; or test \"\$_scratch_target\" = HOME" \
|
|
272
|
+
" if not builtin functions -q \$_valise_fish_persistence_verify_helper; or not builtin test (builtin functions \$_valise_fish_persistence_verify_helper | string collect) = \"\$_valise_fish_persistence_helper_definition\"" \
|
|
273
|
+
" builtin printf '%s\\n' 'trusted universal persistence verifier was modified' >&2" \
|
|
274
|
+
" return 125" \
|
|
275
|
+
" end" \
|
|
276
|
+
" \$_valise_fish_persistence_verify_helper \"\$_valise_fish_persistence_durable_file\" \"\$_valise_fish_persistence_tmp_parent\" \"\$_scratch_target\" \"\$\$_scratch_universal_present_var\" \"\$\$_scratch_universal_exported_var\" \$\$_scratch_universal_values_var; or return 125" \
|
|
277
|
+
" end" \
|
|
278
|
+
" for _scratch_suffix in global_present global_exported global_values universal_present universal_exported universal_values" \
|
|
279
|
+
" set -l _scratch_snapshot_name \"\$_scratch_prefix\"_\$_scratch_suffix" \
|
|
280
|
+
" if builtin set -q -l \"\$_scratch_snapshot_name\"" \
|
|
281
|
+
" builtin set -e -l \"\$_scratch_snapshot_name\"; or return 125" \
|
|
282
|
+
" end" \
|
|
283
|
+
" if builtin set -q -g \"\$_scratch_snapshot_name\"" \
|
|
284
|
+
" builtin set -e -g \"\$_scratch_snapshot_name\"; or return 125" \
|
|
285
|
+
" end" \
|
|
286
|
+
" if builtin set -q -U \"\$_scratch_snapshot_name\"" \
|
|
287
|
+
" builtin set -e -U \"\$_scratch_snapshot_name\"; or return 125" \
|
|
288
|
+
" end" \
|
|
289
|
+
" end" \
|
|
290
|
+
"end" \
|
|
291
|
+
"set -l _valise_fish_persistence_verify_helper __valise_fish_verify_(builtin random)" \
|
|
292
|
+
"function \$_valise_fish_persistence_verify_helper --no-scope-shadowing" \
|
|
293
|
+
" set -l _persistence_durable_file \$argv[1]" \
|
|
294
|
+
" set -l _persistence_tmp_parent \$argv[2]" \
|
|
295
|
+
" set -l _persistence_scope \$argv[3]" \
|
|
296
|
+
" set -l _persistence_expected_present \$argv[4]" \
|
|
297
|
+
" set -l _persistence_expected_exported \$argv[5]" \
|
|
298
|
+
" set -l _persistence_expected_values \$argv[6..-1]" \
|
|
299
|
+
" set -l _persistence_fish_path (status fish-path)" \
|
|
300
|
+
" if test (builtin count \$_persistence_fish_path) -ne 1; or not test -x \"\$_persistence_fish_path\"" \
|
|
301
|
+
" return 125" \
|
|
302
|
+
" end" \
|
|
303
|
+
" # _persistence_durable_file was captured before untrusted source execution." \
|
|
304
|
+
" if not test -f \"\$_persistence_durable_file\"" \
|
|
305
|
+
" if test \"\$_persistence_expected_present\" = 0" \
|
|
306
|
+
" return 0" \
|
|
307
|
+
" end" \
|
|
308
|
+
" return 125" \
|
|
309
|
+
" end" \
|
|
310
|
+
" if not string match -q '/*' -- \"\$_persistence_tmp_parent\"; or not test -d \"\$_persistence_tmp_parent\"; or not test -w \"\$_persistence_tmp_parent\"; or not test -x \"\$_persistence_tmp_parent\"" \
|
|
311
|
+
" return 125" \
|
|
312
|
+
" end" \
|
|
313
|
+
" set -l _persistence_checked_file \$_persistence_durable_file" \
|
|
314
|
+
" if test -x /usr/bin/uname; and test (/usr/bin/uname -s 2>/dev/null) = Darwin" \
|
|
315
|
+
" if builtin test -L /var; and test (builtin path resolve -- /var 2>/dev/null) = /private/var" \
|
|
316
|
+
" set _persistence_checked_file (builtin string replace -r '^/var' /private/var -- \"\$_persistence_checked_file\")" \
|
|
317
|
+
" end" \
|
|
318
|
+
" if builtin test -L /tmp; and test (builtin path resolve -- /tmp 2>/dev/null) = /private/tmp" \
|
|
319
|
+
" set _persistence_checked_file (builtin string replace -r '^/tmp' /private/tmp -- \"\$_persistence_checked_file\")" \
|
|
320
|
+
" end" \
|
|
321
|
+
" end" \
|
|
322
|
+
" if not builtin string match -q '/*' -- \"\$_persistence_checked_file\"; or builtin string match -q '*//*' -- \"\$_persistence_checked_file\"" \
|
|
323
|
+
" return 125" \
|
|
324
|
+
" end" \
|
|
325
|
+
" set -l _persistence_checked_prefix /" \
|
|
326
|
+
" for _persistence_checked_component in (builtin string split '/' -- \"\$_persistence_checked_file\")" \
|
|
327
|
+
" if test -z \"\$_persistence_checked_component\"" \
|
|
328
|
+
" continue" \
|
|
329
|
+
" end" \
|
|
330
|
+
" switch \"\$_persistence_checked_component\"" \
|
|
331
|
+
" case . .." \
|
|
332
|
+
" return 125" \
|
|
333
|
+
" end" \
|
|
334
|
+
" if test \"\$_persistence_checked_prefix\" = /" \
|
|
335
|
+
" set _persistence_checked_prefix /\$_persistence_checked_component" \
|
|
336
|
+
" else" \
|
|
337
|
+
" set _persistence_checked_prefix \"\$_persistence_checked_prefix/\$_persistence_checked_component\"" \
|
|
338
|
+
" end" \
|
|
339
|
+
" if builtin test -L \"\$_persistence_checked_prefix\"" \
|
|
340
|
+
" return 125" \
|
|
341
|
+
" end" \
|
|
342
|
+
" end" \
|
|
343
|
+
" set -e _persistence_checked_file _persistence_checked_prefix _persistence_checked_component" \
|
|
344
|
+
" set -l _persistence_mktemp_path ''" \
|
|
345
|
+
" for _persistence_candidate in /usr/bin/mktemp /bin/mktemp" \
|
|
346
|
+
" if test -x \"\$_persistence_candidate\"" \
|
|
347
|
+
" set _persistence_mktemp_path \"\$_persistence_candidate\"" \
|
|
348
|
+
" break" \
|
|
349
|
+
" end" \
|
|
350
|
+
" end" \
|
|
351
|
+
" set -l _persistence_mkdir_path ''" \
|
|
352
|
+
" for _persistence_candidate in /bin/mkdir /usr/bin/mkdir" \
|
|
353
|
+
" if test -x \"\$_persistence_candidate\"" \
|
|
354
|
+
" set _persistence_mkdir_path \"\$_persistence_candidate\"" \
|
|
355
|
+
" break" \
|
|
356
|
+
" end" \
|
|
357
|
+
" end" \
|
|
358
|
+
" set -l _persistence_ln_path ''" \
|
|
359
|
+
" for _persistence_candidate in /bin/ln /usr/bin/ln" \
|
|
360
|
+
" if test -x \"\$_persistence_candidate\"" \
|
|
361
|
+
" set _persistence_ln_path \"\$_persistence_candidate\"" \
|
|
362
|
+
" break" \
|
|
363
|
+
" end" \
|
|
364
|
+
" end" \
|
|
365
|
+
" set -l _persistence_rm_path ''" \
|
|
366
|
+
" for _persistence_candidate in /bin/rm /usr/bin/rm" \
|
|
367
|
+
" if test -x \"\$_persistence_candidate\"" \
|
|
368
|
+
" set _persistence_rm_path \"\$_persistence_candidate\"" \
|
|
369
|
+
" break" \
|
|
370
|
+
" end" \
|
|
371
|
+
" end" \
|
|
372
|
+
" if test -z \"\$_persistence_mktemp_path\"; or test -z \"\$_persistence_mkdir_path\"; or test -z \"\$_persistence_ln_path\"; or test -z \"\$_persistence_rm_path\"" \
|
|
373
|
+
" return 125" \
|
|
374
|
+
" end" \
|
|
375
|
+
" set -l _persistence_verify_root (\"\$_persistence_mktemp_path\" -d \"\$_persistence_tmp_parent/valise-fish-persistence.XXXXXX\" 2>/dev/null)" \
|
|
376
|
+
" if test \$status -ne 0; or test (builtin count \$_persistence_verify_root) -ne 1" \
|
|
377
|
+
" return 125" \
|
|
378
|
+
" end" \
|
|
379
|
+
" if not \"\$_persistence_mkdir_path\" -p \"\$_persistence_verify_root/fish\"; or not \"\$_persistence_ln_path\" -s \"\$_persistence_durable_file\" \"\$_persistence_verify_root/fish/fish_variables\"" \
|
|
380
|
+
" if not \"\$_persistence_rm_path\" -rf -- \"\$_persistence_verify_root\" 2>/dev/null" \
|
|
381
|
+
" return 125" \
|
|
382
|
+
" end" \
|
|
383
|
+
" return 125" \
|
|
384
|
+
" end" \
|
|
385
|
+
" set -lx XDG_CONFIG_HOME \"\$_persistence_verify_root\"" \
|
|
386
|
+
" set -l _persistence_actual (\"\$_persistence_fish_path\" -c '" \
|
|
387
|
+
" set -l _persistence_name \$argv[1]" \
|
|
388
|
+
" # Remove an inherited global shadow before reading the universal store." \
|
|
389
|
+
" if builtin set -q -g -- \$_persistence_name" \
|
|
390
|
+
" set -l _persistence_global_values \$\$_persistence_name" \
|
|
391
|
+
" builtin set -e -g -- \$_persistence_name; or exit 125" \
|
|
392
|
+
" end" \
|
|
393
|
+
" if builtin set -q -U -- \$_persistence_name" \
|
|
394
|
+
" builtin printf \"1\\n\"" \
|
|
395
|
+
" if builtin set -q -Ux -- \$_persistence_name" \
|
|
396
|
+
" builtin printf \"1\\n\"" \
|
|
397
|
+
" else" \
|
|
398
|
+
" builtin printf \"0\\n\"" \
|
|
399
|
+
" end" \
|
|
400
|
+
" string escape -- \$\$_persistence_name" \
|
|
401
|
+
" else" \
|
|
402
|
+
" builtin printf \"0\\n0\\n\"" \
|
|
403
|
+
" end" \
|
|
404
|
+
" ' -- \"\$_persistence_scope\" 2>/dev/null)" \
|
|
405
|
+
" set -l _persistence_child_status \$status" \
|
|
406
|
+
" if not \"\$_persistence_rm_path\" -rf -- \"\$_persistence_verify_root\" 2>/dev/null" \
|
|
407
|
+
" return 125" \
|
|
408
|
+
" end" \
|
|
409
|
+
" if test \$_persistence_child_status -ne 0" \
|
|
410
|
+
" return 125" \
|
|
411
|
+
" end" \
|
|
412
|
+
" set -l _persistence_expected \$_persistence_expected_present \$_persistence_expected_exported" \
|
|
413
|
+
" set -a _persistence_expected (string escape -- \$_persistence_expected_values)" \
|
|
414
|
+
" if test (builtin count \$_persistence_actual) -ne (builtin count \$_persistence_expected)" \
|
|
415
|
+
" return 125" \
|
|
416
|
+
" end" \
|
|
417
|
+
" set -l _persistence_index 1" \
|
|
418
|
+
" while test \$_persistence_index -le (builtin count \$_persistence_expected)" \
|
|
419
|
+
" if not builtin test \"\$_persistence_actual[\$_persistence_index]\" = \"\$_persistence_expected[\$_persistence_index]\"" \
|
|
420
|
+
" return 125" \
|
|
421
|
+
" end" \
|
|
422
|
+
" set _persistence_index (builtin math \$_persistence_index + 1)" \
|
|
423
|
+
" end" \
|
|
424
|
+
" return 0" \
|
|
425
|
+
"end" \
|
|
426
|
+
"# Restore persistent caller root scopes and remove the temporary snapshot state." \
|
|
427
|
+
"set -l _valise_fish_root_restore_helper __valise_fish_restore_(builtin random)" \
|
|
428
|
+
"function \$_valise_fish_root_restore_helper --no-scope-shadowing" \
|
|
429
|
+
" if builtin set -q -g SHELL_PROJECT_ROOT" \
|
|
430
|
+
" builtin set -e -g SHELL_PROJECT_ROOT; or return 125" \
|
|
431
|
+
" end" \
|
|
432
|
+
" if builtin set -q -U SHELL_PROJECT_ROOT" \
|
|
433
|
+
" builtin set -e -U SHELL_PROJECT_ROOT; or return 125" \
|
|
434
|
+
" end" \
|
|
435
|
+
" if builtin test \$_valise_fish_root_global_set -eq 1" \
|
|
436
|
+
" set -l _valise_fish_root_global_flags -g" \
|
|
437
|
+
" if builtin test \$_valise_fish_root_global_exported -eq 1" \
|
|
438
|
+
" set _valise_fish_root_global_flags -gx" \
|
|
439
|
+
" end" \
|
|
440
|
+
" builtin set \$_valise_fish_root_global_flags SHELL_PROJECT_ROOT \$_valise_fish_root_global_values" \
|
|
441
|
+
" if test \$status -ne 0" \
|
|
442
|
+
" return 125" \
|
|
443
|
+
" end" \
|
|
444
|
+
" end" \
|
|
445
|
+
" if not builtin functions -q \$_valise_fish_persistence_verify_helper; or not builtin test (builtin functions \$_valise_fish_persistence_verify_helper | string collect) = \"\$_valise_fish_persistence_helper_definition\"" \
|
|
446
|
+
" builtin printf '%s\\n' 'trusted universal persistence verifier was modified' >&2" \
|
|
447
|
+
" return 125" \
|
|
448
|
+
" end" \
|
|
449
|
+
" if builtin test \$_valise_fish_root_universal_set -eq 1" \
|
|
450
|
+
" set -l _valise_fish_root_universal_flags -U" \
|
|
451
|
+
" if builtin test \$_valise_fish_root_universal_exported -eq 1" \
|
|
452
|
+
" set _valise_fish_root_universal_flags -Ux" \
|
|
453
|
+
" end" \
|
|
454
|
+
" builtin set \$_valise_fish_root_universal_flags SHELL_PROJECT_ROOT \$_valise_fish_root_universal_values" \
|
|
455
|
+
" if test \$status -ne 0" \
|
|
456
|
+
" return 125" \
|
|
457
|
+
" end" \
|
|
458
|
+
" end" \
|
|
459
|
+
" \$_valise_fish_persistence_verify_helper \"\$_valise_fish_persistence_durable_file\" \"\$_valise_fish_persistence_tmp_parent\" SHELL_PROJECT_ROOT \"\$_valise_fish_root_universal_set\" \"\$_valise_fish_root_universal_exported\" \$_valise_fish_root_universal_values; or return 125" \
|
|
460
|
+
" for _valise_fish_root_state in _valise_fish_root_global_set _valise_fish_root_global_exported _valise_fish_root_global_values _valise_fish_root_universal_set _valise_fish_root_universal_exported _valise_fish_root_universal_values" \
|
|
461
|
+
" if builtin set -q -l \$_valise_fish_root_state" \
|
|
462
|
+
" builtin set -e -l \$_valise_fish_root_state; or return 125" \
|
|
463
|
+
" end" \
|
|
464
|
+
" end" \
|
|
465
|
+
" for _valise_fish_scratch_name in \$_valise_fish_scratch_names" \
|
|
466
|
+
" if not builtin functions -q \$_valise_fish_scratch_restore_helper; or not builtin test (builtin functions \$_valise_fish_scratch_restore_helper | string collect) = \"\$_valise_fish_scratch_helper_definition\"" \
|
|
467
|
+
" builtin printf '%s\\n' 'trusted scratch restore helper was modified' >&2" \
|
|
468
|
+
" builtin exit 125" \
|
|
469
|
+
" end" \
|
|
470
|
+
" \$_valise_fish_scratch_restore_helper \"\$_valise_fish_scratch_name\" \"\$_valise_fish_scratch_prefix\"; or return 125" \
|
|
471
|
+
" end" \
|
|
472
|
+
" if builtin set -q _valise_fish_persistence_verify_helper; and builtin functions -q \"\$_valise_fish_persistence_verify_helper\"" \
|
|
473
|
+
" builtin functions -e \"\$_valise_fish_persistence_verify_helper\"; or return 125" \
|
|
474
|
+
" end" \
|
|
475
|
+
" builtin functions -e (builtin status function) 2>/dev/null" \
|
|
476
|
+
"end" \
|
|
477
|
+
"# Publish only the authenticated active root and readiness marker. Untrusted" \
|
|
478
|
+
"# source may have left universal shadows behind, so remove them before the" \
|
|
479
|
+
"# global public state is exposed." \
|
|
480
|
+
"set -l _valise_fish_publish_active_helper __valise_fish_publish_(builtin random)" \
|
|
481
|
+
"function \$_valise_fish_publish_active_helper --no-scope-shadowing" \
|
|
482
|
+
" if builtin set -q -U SHELL_PROJECT_ROOT" \
|
|
483
|
+
" builtin set -e -U SHELL_PROJECT_ROOT; or return 125" \
|
|
484
|
+
" end" \
|
|
485
|
+
" builtin set -gx SHELL_PROJECT_ROOT \"\$_valise_fish_active_root\"; or return 125" \
|
|
486
|
+
" if builtin set -q -U VALISE_FISH_READY" \
|
|
487
|
+
" builtin set -e -U VALISE_FISH_READY; or return 125" \
|
|
488
|
+
" end" \
|
|
489
|
+
" builtin set -gx VALISE_FISH_READY 1; or return 125" \
|
|
490
|
+
"end" \
|
|
491
|
+
"set -l _valise_fish_publish_active_helper_definition (builtin functions \"\$_valise_fish_publish_active_helper\" | string collect)" \
|
|
492
|
+
"# Successful activation keeps the authenticated public root/readiness state." \
|
|
493
|
+
"# It only removes private snapshots and trusted helper functions; rollback" \
|
|
494
|
+
"# is reserved for failure paths." \
|
|
495
|
+
"set -l _valise_fish_success_cleanup_helper __valise_fish_cleanup_(builtin random)" \
|
|
496
|
+
"function \$_valise_fish_success_cleanup_helper --no-scope-shadowing" \
|
|
497
|
+
" if not builtin functions -q \$_valise_fish_success_cleanup_helper; or not builtin test (builtin functions \$_valise_fish_success_cleanup_helper | string collect) = \"\$_valise_fish_success_cleanup_helper_definition\"" \
|
|
498
|
+
" builtin printf '%s\\n' 'trusted success cleanup helper was modified' >&2" \
|
|
499
|
+
" return 125" \
|
|
500
|
+
" end" \
|
|
501
|
+
" for _valise_fish_root_state in _valise_fish_root_global_set _valise_fish_root_global_exported _valise_fish_root_global_values _valise_fish_root_universal_set _valise_fish_root_universal_exported _valise_fish_root_universal_values" \
|
|
502
|
+
" if builtin set -q -l \$_valise_fish_root_state" \
|
|
503
|
+
" builtin set -e -l \$_valise_fish_root_state; or return 125" \
|
|
504
|
+
" end" \
|
|
505
|
+
" end" \
|
|
506
|
+
" if not builtin functions -q \$_valise_fish_scratch_restore_helper; or not builtin test (builtin functions \$_valise_fish_scratch_restore_helper | string collect) = \"\$_valise_fish_scratch_restore_helper_definition\"" \
|
|
507
|
+
" builtin printf '%s\\n' 'trusted scratch restore helper was modified' >&2" \
|
|
508
|
+
" return 125" \
|
|
509
|
+
" end" \
|
|
510
|
+
" for _valise_fish_scratch_name in \$_valise_fish_scratch_names" \
|
|
511
|
+
" if not builtin functions -q \$_valise_fish_scratch_restore_helper; or not builtin test (builtin functions \$_valise_fish_scratch_restore_helper | string collect) = \"\$_valise_fish_scratch_helper_definition\"" \
|
|
512
|
+
" builtin printf '%s\\n' 'trusted scratch restore helper was modified' >&2" \
|
|
513
|
+
" return 125" \
|
|
514
|
+
" end" \
|
|
515
|
+
" \$_valise_fish_scratch_restore_helper \"\$_valise_fish_scratch_name\" \"\$_valise_fish_scratch_prefix\"; or return 125" \
|
|
516
|
+
" end" \
|
|
517
|
+
" if builtin set -q _valise_fish_publish_active_helper; and builtin functions -q \"\$_valise_fish_publish_active_helper\"" \
|
|
518
|
+
" if not builtin test (builtin functions \"\$_valise_fish_publish_active_helper\" | string collect) = \"\$_valise_fish_publish_active_helper_definition\"" \
|
|
519
|
+
" builtin printf '%s\\n' 'trusted active-state publisher was modified' >&2" \
|
|
520
|
+
" return 125" \
|
|
521
|
+
" end" \
|
|
522
|
+
" builtin functions -e \"\$_valise_fish_publish_active_helper\"; or return 125" \
|
|
523
|
+
" end" \
|
|
524
|
+
" if builtin set -q _valise_fish_persistence_verify_helper; and builtin functions -q \"\$_valise_fish_persistence_verify_helper\"" \
|
|
525
|
+
" if not builtin test (builtin functions \"\$_valise_fish_persistence_verify_helper\" | string collect) = \"\$_valise_fish_persistence_helper_definition\"" \
|
|
526
|
+
" builtin printf '%s\\n' 'trusted universal persistence verifier was modified' >&2" \
|
|
527
|
+
" return 125" \
|
|
528
|
+
" end" \
|
|
529
|
+
" builtin functions -e \"\$_valise_fish_persistence_verify_helper\"; or return 125" \
|
|
530
|
+
" end" \
|
|
531
|
+
" if builtin set -q _valise_fish_owned_cleanup; and builtin functions -q \"\$_valise_fish_owned_cleanup\"" \
|
|
532
|
+
" builtin functions -e \"\$_valise_fish_owned_cleanup\"; or return 125" \
|
|
533
|
+
" end" \
|
|
534
|
+
" if builtin set -q _valise_fish_persistence_path_physical_helper; and builtin functions -q \"\$_valise_fish_persistence_path_physical_helper\"" \
|
|
535
|
+
" builtin functions -e \"\$_valise_fish_persistence_path_physical_helper\"; or return 125" \
|
|
536
|
+
" end" \
|
|
537
|
+
" if builtin functions -q \"\$_valise_fish_root_restore_helper\"" \
|
|
538
|
+
" if not builtin test (builtin functions \"\$_valise_fish_root_restore_helper\" | string collect) = \"\$_valise_fish_root_helper_definition\"" \
|
|
539
|
+
" builtin printf '%s\\n' 'trusted root restore helper was modified' >&2" \
|
|
540
|
+
" return 125" \
|
|
541
|
+
" end" \
|
|
542
|
+
" builtin functions -e \"\$_valise_fish_root_restore_helper\"; or return 125" \
|
|
543
|
+
" end" \
|
|
544
|
+
" if builtin functions -q \"\$_valise_fish_scratch_restore_helper\"" \
|
|
545
|
+
" if not builtin test (builtin functions \"\$_valise_fish_scratch_restore_helper\" | string collect) = \"\$_valise_fish_scratch_restore_helper_definition\"" \
|
|
546
|
+
" builtin printf '%s\\n' 'trusted scratch restore helper was modified' >&2" \
|
|
547
|
+
" return 125" \
|
|
548
|
+
" end" \
|
|
549
|
+
" builtin functions -e \"\$_valise_fish_scratch_restore_helper\"; or return 125" \
|
|
550
|
+
" end" \
|
|
551
|
+
" builtin functions -e (builtin status function) 2>/dev/null; or return 125" \
|
|
552
|
+
"end" \
|
|
553
|
+
"# Keep cleanup definitions outside the Fish function namespace while" \
|
|
554
|
+
"# untrusted entrypoints and generated plans are executing. Function names" \
|
|
555
|
+
"# are enumerable, so the trusted definitions stay in caller-local Fish" \
|
|
556
|
+
"# variables rather than same-user-writable temporary files." \
|
|
557
|
+
"set -l _valise_fish_root_helper_definition (builtin functions \"\$_valise_fish_root_restore_helper\" | string collect)" \
|
|
558
|
+
"set -l _valise_fish_success_cleanup_helper_definition (builtin functions \"\$_valise_fish_success_cleanup_helper\" | string collect)" \
|
|
559
|
+
"set -l _valise_fish_persistence_helper_definition (builtin functions \"\$_valise_fish_persistence_verify_helper\" | string collect)" \
|
|
560
|
+
"set -l _valise_fish_scratch_helper_definition (builtin functions \"\$_valise_fish_scratch_restore_helper\" | string collect)" \
|
|
561
|
+
"set -l _valise_fish_scratch_restore_helper_definition (builtin functions \"\$_valise_fish_scratch_restore_helper\" | string collect)" \
|
|
562
|
+
"if test (builtin count \$_valise_fish_root_helper_definition) -ne 1; or test (builtin count \$_valise_fish_success_cleanup_helper_definition) -ne 1; or test (builtin count \$_valise_fish_publish_active_helper_definition) -ne 1; or test (builtin count \$_valise_fish_persistence_helper_definition) -ne 1; or test (builtin count \$_valise_fish_scratch_helper_definition) -ne 1; or test (builtin count \$_valise_fish_scratch_restore_helper_definition) -ne 1" \
|
|
563
|
+
" printf '%s\\n' 'valise Fish integration: trusted cleanup snapshot unavailable' >&2" \
|
|
564
|
+
" return 125" \
|
|
565
|
+
"end" \
|
|
566
|
+
"# Clear handshake and readiness in both persistent scopes before activation." \
|
|
567
|
+
"for _valise_fish_state_name in VALISE_FISH_READY _sp_fish_loader_bootstrap_status _sp_fish_loader_bootstrap_mode _sp_fish_loader_bootstrap_seeds _sp_fish_loader_expected_source _sp_fish_metadata_expected_source VALISE_MODULE_ROOT" \
|
|
568
|
+
" if builtin set -q -g \"\$_valise_fish_state_name\"; and not builtin set -e -g \"\$_valise_fish_state_name\"; builtin exit 125; end" \
|
|
569
|
+
" if builtin set -q -U \"\$_valise_fish_state_name\"; and not builtin set -e -U \"\$_valise_fish_state_name\"; builtin exit 125; end" \
|
|
570
|
+
"end" \
|
|
571
|
+
"# Cleanup only functions whose exact current source matches an authenticated ownership ledger." \
|
|
572
|
+
"# Installed ledgers are accepted only for complete, authenticated release roots; source-tree mode is intentionally broader because it is an unauthenticated development surface." \
|
|
573
|
+
"set -l _valise_fish_active_root" \
|
|
574
|
+
"if test \"\$_valise_fish_source_tree_mode\" = 1" \
|
|
575
|
+
" set _valise_fish_active_root (builtin path resolve -- ${_fish_active_literal})" \
|
|
576
|
+
"else" \
|
|
577
|
+
" set _valise_fish_active_root (${_fish_cli_literal} release verify --print-root 2>/dev/null)" \
|
|
578
|
+
"end" \
|
|
579
|
+
"set -l _valise_fish_owned_cleanup __valise_fish_owned_cleanup_(builtin random)" \
|
|
580
|
+
"function \$_valise_fish_owned_cleanup --no-scope-shadowing" \
|
|
581
|
+
" set -l _valise_fish_trusted_root \$_valise_fish_active_root" \
|
|
582
|
+
" set -l _valise_fish_ledger_invalid 0" \
|
|
583
|
+
" # Without an authenticated release no ledger can be authenticated; with no" \
|
|
584
|
+
" # ledger at all there is nothing to clean, and the caller reports the" \
|
|
585
|
+
" # authentication failure itself." \
|
|
586
|
+
" if not builtin test -n \"\$_valise_fish_trusted_root\"" \
|
|
587
|
+
" for _valise_fish_ledger_name in _sp_fish_loader_owned_exports _sp_fish_loader_owned_sources _sp_fish_legacy_owned_exports _sp_fish_legacy_owned_sources _sp_fish_metadata_owned_exports _sp_fish_metadata_owned_sources _sp_fish_entrypoint_owned_exports _sp_fish_entrypoint_owned_sources" \
|
|
588
|
+
" builtin set -q \$_valise_fish_ledger_name; and set _valise_fish_ledger_invalid 1" \
|
|
589
|
+
" end" \
|
|
590
|
+
" end" \
|
|
591
|
+
" for _valise_fish_ledger_name in _sp_fish_loader_owned_exports _sp_fish_legacy_owned_exports _sp_fish_metadata_owned_exports _sp_fish_entrypoint_owned_exports" \
|
|
592
|
+
" set -l _valise_fish_source_ledger_name ''" \
|
|
593
|
+
" switch \"\$_valise_fish_ledger_name\"" \
|
|
594
|
+
" case _sp_fish_loader_owned_exports" \
|
|
595
|
+
" set _valise_fish_source_ledger_name _sp_fish_loader_owned_sources" \
|
|
596
|
+
" case _sp_fish_legacy_owned_exports" \
|
|
597
|
+
" set _valise_fish_source_ledger_name _sp_fish_legacy_owned_sources" \
|
|
598
|
+
" case _sp_fish_metadata_owned_exports" \
|
|
599
|
+
" set _valise_fish_source_ledger_name _sp_fish_metadata_owned_sources" \
|
|
600
|
+
" case _sp_fish_entrypoint_owned_exports" \
|
|
601
|
+
" set _valise_fish_source_ledger_name _sp_fish_entrypoint_owned_sources" \
|
|
602
|
+
" end" \
|
|
603
|
+
" set -l _valise_fish_ledger_present 0" \
|
|
604
|
+
" set -l _valise_fish_source_present 0" \
|
|
605
|
+
" builtin set -q \$_valise_fish_ledger_name; and set _valise_fish_ledger_present 1" \
|
|
606
|
+
" builtin set -q \$_valise_fish_source_ledger_name; and set _valise_fish_source_present 1" \
|
|
607
|
+
" if builtin test \$_valise_fish_ledger_present -ne \$_valise_fish_source_present" \
|
|
608
|
+
" set _valise_fish_ledger_invalid 1" \
|
|
609
|
+
" else if builtin test \$_valise_fish_ledger_present -eq 1" \
|
|
610
|
+
" set -l _valise_fish_owned_names \$\$_valise_fish_ledger_name" \
|
|
611
|
+
" set -l _valise_fish_owned_sources \$\$_valise_fish_source_ledger_name" \
|
|
612
|
+
" if builtin test (builtin count \$_valise_fish_owned_names) -ne (builtin count \$_valise_fish_owned_sources)" \
|
|
613
|
+
" set _valise_fish_ledger_invalid 1" \
|
|
614
|
+
" else" \
|
|
615
|
+
" set -l _valise_fish_owned_index 1" \
|
|
616
|
+
" for _valise_fish_owned_source in \$_valise_fish_owned_sources" \
|
|
617
|
+
" set -l _valise_fish_source_valid 0" \
|
|
618
|
+
" if builtin string match -q 'embedded:*' -- \"\$_valise_fish_owned_source\"; or builtin string match -q 'autoloaded:*' -- \"\$_valise_fish_owned_source\"; or builtin string match -q 'builtin' -- \"\$_valise_fish_owned_source\"" \
|
|
619
|
+
" set _valise_fish_source_valid 1" \
|
|
620
|
+
" else if builtin test \"\$_valise_fish_source_tree_mode\" = 1; and builtin test -f \"\$_valise_fish_owned_source\"" \
|
|
621
|
+
" set -l _valise_fish_source_canonical (builtin path resolve -- \"\$_valise_fish_owned_source\" 2>/dev/null)" \
|
|
622
|
+
" if builtin string match -q \"\$_valise_fish_trusted_root/*\" -- \"\$_valise_fish_source_canonical\"" \
|
|
623
|
+
" set _valise_fish_source_valid 1" \
|
|
624
|
+
" else if builtin test -n \"\$_valise_fish_previous_root\"; and builtin string match -q \"\$_valise_fish_previous_root/*\" -- \"\$_valise_fish_source_canonical\"" \
|
|
625
|
+
" set _valise_fish_source_valid 1" \
|
|
626
|
+
" end" \
|
|
627
|
+
" else if builtin test \"\$_valise_fish_source_tree_mode\" != 1" \
|
|
628
|
+
" # Every installed release is sealed and immutable, so a function whose" \
|
|
629
|
+
" # source resolves inside the release store came from a release: the" \
|
|
630
|
+
" # active one, or the one this shell loaded before a switch." \
|
|
631
|
+
" set -l _valise_fish_releases_root (builtin path dirname -- \"\$_valise_fish_trusted_root\")" \
|
|
632
|
+
" set -l _valise_fish_source_canonical (builtin path resolve -- \"\$_valise_fish_owned_source\" 2>/dev/null)" \
|
|
633
|
+
" if builtin test -f \"\$_valise_fish_owned_source\"; and builtin string match -q \"\$_valise_fish_releases_root/*\" -- \"\$_valise_fish_source_canonical\"" \
|
|
634
|
+
" set _valise_fish_source_valid 1" \
|
|
635
|
+
" end" \
|
|
636
|
+
" end" \
|
|
637
|
+
" if builtin test \$_valise_fish_source_valid -ne 1" \
|
|
638
|
+
" set _valise_fish_ledger_invalid 1" \
|
|
639
|
+
" break" \
|
|
640
|
+
" end" \
|
|
641
|
+
" set _valise_fish_owned_index (builtin math \$_valise_fish_owned_index + 1)" \
|
|
642
|
+
" end" \
|
|
643
|
+
" end" \
|
|
644
|
+
" end" \
|
|
645
|
+
" end" \
|
|
646
|
+
" if builtin test \$_valise_fish_ledger_invalid -ne 0" \
|
|
647
|
+
" for _valise_fish_ledger_name in _sp_fish_loader_owned_exports _sp_fish_loader_owned_sources _sp_fish_legacy_owned_exports _sp_fish_legacy_owned_sources _sp_fish_metadata_owned_exports _sp_fish_metadata_owned_sources _sp_fish_entrypoint_owned_exports _sp_fish_entrypoint_owned_sources" \
|
|
648
|
+
" if builtin set -q -g \"\$_valise_fish_ledger_name\"; and not builtin set -e -g \"\$_valise_fish_ledger_name\"; builtin exit 125; end" \
|
|
649
|
+
" if builtin set -q -U \"\$_valise_fish_ledger_name\"; and not builtin set -e -U \"\$_valise_fish_ledger_name\"; builtin exit 125; end" \
|
|
650
|
+
" end" \
|
|
651
|
+
" builtin printf '%s\n' 'valise Fish integration: ownership ledger is not authenticated' >&2" \
|
|
652
|
+
" return 125" \
|
|
653
|
+
" end" \
|
|
654
|
+
" for _valise_fish_ledger_name in _sp_fish_loader_owned_exports _sp_fish_legacy_owned_exports _sp_fish_metadata_owned_exports _sp_fish_entrypoint_owned_exports" \
|
|
655
|
+
" set -l _valise_fish_source_ledger_name ''" \
|
|
656
|
+
" switch \"\$_valise_fish_ledger_name\"" \
|
|
657
|
+
" case _sp_fish_loader_owned_exports" \
|
|
658
|
+
" set _valise_fish_source_ledger_name _sp_fish_loader_owned_sources" \
|
|
659
|
+
" case _sp_fish_legacy_owned_exports" \
|
|
660
|
+
" set _valise_fish_source_ledger_name _sp_fish_legacy_owned_sources" \
|
|
661
|
+
" case _sp_fish_metadata_owned_exports" \
|
|
662
|
+
" set _valise_fish_source_ledger_name _sp_fish_metadata_owned_sources" \
|
|
663
|
+
" case _sp_fish_entrypoint_owned_exports" \
|
|
664
|
+
" set _valise_fish_source_ledger_name _sp_fish_entrypoint_owned_sources" \
|
|
665
|
+
" end" \
|
|
666
|
+
" if builtin set -q \"\$_valise_fish_ledger_name\"; and builtin set -q \"\$_valise_fish_source_ledger_name\"" \
|
|
667
|
+
" set -l _valise_fish_owned_index 1" \
|
|
668
|
+
" for _valise_fish_owned_function in \$\$_valise_fish_ledger_name" \
|
|
669
|
+
" set -l _valise_fish_owned_sources \$\$_valise_fish_source_ledger_name" \
|
|
670
|
+
" set -l _valise_fish_owned_source \$_valise_fish_owned_sources[\$_valise_fish_owned_index]" \
|
|
671
|
+
" if test -n \"\$_valise_fish_owned_source\"; and builtin functions -q \"\$_valise_fish_owned_function\"; and builtin test (builtin functions --details \"\$_valise_fish_owned_function\") = \"\$_valise_fish_owned_source\"" \
|
|
672
|
+
" builtin functions -e \"\$_valise_fish_owned_function\"; or builtin exit 125" \
|
|
673
|
+
" end" \
|
|
674
|
+
" set _valise_fish_owned_index (builtin math \$_valise_fish_owned_index + 1)" \
|
|
675
|
+
" end" \
|
|
676
|
+
" end" \
|
|
677
|
+
" if builtin set -q -g \"\$_valise_fish_ledger_name\"; and not builtin set -e -g \"\$_valise_fish_ledger_name\"; builtin exit 125; end" \
|
|
678
|
+
" if builtin set -q -U \"\$_valise_fish_ledger_name\"; and not builtin set -e -U \"\$_valise_fish_ledger_name\"; builtin exit 125; end" \
|
|
679
|
+
" if builtin set -q -g \"\$_valise_fish_source_ledger_name\"; and not builtin set -e -g \"\$_valise_fish_source_ledger_name\"; builtin exit 125; end" \
|
|
680
|
+
" if builtin set -q -U \"\$_valise_fish_source_ledger_name\"; and not builtin set -e -U \"\$_valise_fish_source_ledger_name\"; builtin exit 125; end" \
|
|
681
|
+
" end" \
|
|
682
|
+
" return 0" \
|
|
683
|
+
"end" \
|
|
684
|
+
"set -l _valise_fish_owned_cleanup_definition (builtin functions \"\$_valise_fish_owned_cleanup\" | string collect)" \
|
|
685
|
+
"if test (builtin count \"\$_valise_fish_owned_cleanup_definition\") -ne 1" \
|
|
686
|
+
" printf '%s\\n' 'valise Fish integration: trusted ownership cleanup snapshot unavailable' >&2" \
|
|
687
|
+
" return 125" \
|
|
688
|
+
"end" \
|
|
689
|
+
"if not builtin functions -q \$_valise_fish_owned_cleanup; or not builtin test (builtin functions \$_valise_fish_owned_cleanup | string collect) = \"\$_valise_fish_owned_cleanup_definition\"" \
|
|
690
|
+
" builtin printf '%s\\n' 'trusted ownership cleanup helper was modified' >&2" \
|
|
691
|
+
" builtin exit 125" \
|
|
692
|
+
"end" \
|
|
693
|
+
"\$_valise_fish_owned_cleanup \"\$_valise_fish_active_root\" \"\$_valise_fish_source_tree_mode\"" \
|
|
694
|
+
"set -l _valise_fish_owned_cleanup_status \$status" \
|
|
695
|
+
"if test \$_valise_fish_owned_cleanup_status -ne 0" \
|
|
696
|
+
" return \$_valise_fish_owned_cleanup_status" \
|
|
697
|
+
"end" \
|
|
698
|
+
"if test -z \"\$_valise_fish_active_root\"; or not builtin test -d \"\$_valise_fish_active_root\"" \
|
|
699
|
+
" if test \"\$_valise_fish_source_tree_mode\" = 1" \
|
|
700
|
+
" printf '%s\\n' 'valise Fish integration: active release path cannot be resolved' >&2" \
|
|
701
|
+
" else" \
|
|
702
|
+
" printf '%s\\n' 'valise Fish integration: active release authentication failed (run valise release verify)' >&2" \
|
|
703
|
+
" end" \
|
|
704
|
+
" if not builtin functions -q \$_valise_fish_owned_cleanup; or not builtin test (builtin functions \$_valise_fish_owned_cleanup | string collect) = \"\$_valise_fish_owned_cleanup_definition\"" \
|
|
705
|
+
" builtin printf '%s\\n' 'trusted ownership cleanup helper was modified' >&2" \
|
|
706
|
+
" builtin exit 125" \
|
|
707
|
+
" end" \
|
|
708
|
+
" \$_valise_fish_owned_cleanup" \
|
|
709
|
+
" if not builtin functions -q \$_valise_fish_root_restore_helper; or not builtin test (builtin functions \$_valise_fish_root_restore_helper | string collect) = \"\$_valise_fish_root_helper_definition\"" \
|
|
710
|
+
" builtin printf '%s\\n' 'trusted root restore helper was modified' >&2" \
|
|
711
|
+
" builtin exit 125" \
|
|
712
|
+
" end" \
|
|
713
|
+
" \$_valise_fish_root_restore_helper; or builtin exit 125" \
|
|
714
|
+
" return 1" \
|
|
715
|
+
"end" \
|
|
716
|
+
"if test \"\$_valise_fish_source_tree_mode\" != 1" \
|
|
717
|
+
" set -l _valise_fish_reverified_root (${_fish_cli_literal} release verify --print-root 2>/dev/null)" \
|
|
718
|
+
" if not test -x ${_fish_cli_literal}; or not test \"\$_valise_fish_reverified_root\" = \"\$_valise_fish_active_root\"" \
|
|
719
|
+
" printf '%s\\n' 'valise Fish integration: active release authentication failed' >&2" \
|
|
720
|
+
" if not builtin functions -q \$_valise_fish_owned_cleanup; or not builtin test (builtin functions \$_valise_fish_owned_cleanup | string collect) = \"\$_valise_fish_owned_cleanup_definition\"" \
|
|
721
|
+
" builtin printf '%s\\n' 'trusted ownership cleanup helper was modified' >&2" \
|
|
722
|
+
" builtin exit 125" \
|
|
723
|
+
" end" \
|
|
724
|
+
" \$_valise_fish_owned_cleanup" \
|
|
725
|
+
" if not builtin functions -q \$_valise_fish_root_restore_helper; or not builtin test (builtin functions \$_valise_fish_root_restore_helper | string collect) = \"\$_valise_fish_root_helper_definition\"" \
|
|
726
|
+
" builtin printf '%s\\n' 'trusted root restore helper was modified' >&2" \
|
|
727
|
+
" builtin exit 125" \
|
|
728
|
+
" end" \
|
|
729
|
+
" \$_valise_fish_root_restore_helper; or builtin exit 125" \
|
|
730
|
+
" return 1" \
|
|
731
|
+
" end" \
|
|
732
|
+
"end" \
|
|
733
|
+
"if test -e \"\$_valise_fish_active_root/runtime/fish/profile.fish\"" \
|
|
734
|
+
" set -l _valise_fish_entrypoint_runner __valise_fish_entrypoint_runner_(builtin random)" \
|
|
735
|
+
" function \$_valise_fish_entrypoint_runner" \
|
|
736
|
+
" set -l _entrypoint_file \$argv[1]" \
|
|
737
|
+
" set -l _entrypoint_expected_root \$argv[2]" \
|
|
738
|
+
" set -l _entrypoint_source_tree_mode \$argv[3]" \
|
|
739
|
+
" set -l _entrypoint_previous_root \$argv[4]" \
|
|
740
|
+
" set -l _entrypoint_transaction_name (builtin status function)" \
|
|
741
|
+
" set -l _entrypoint_before (builtin functions --all --names)" \
|
|
742
|
+
" set -l _entrypoint_critical_names contains test string source path functions set printf echo math count eval cd pwd" \
|
|
743
|
+
" set -l _entrypoint_snapshot_names" \
|
|
744
|
+
" set -l _entrypoint_snapshot_definitions" \
|
|
745
|
+
" set -l _entrypoint_snapshot_sources" \
|
|
746
|
+
" for _entrypoint_function in \$_entrypoint_before" \
|
|
747
|
+
" if test \"\$_entrypoint_function\" = \"\$_entrypoint_transaction_name\"; or not builtin functions -q \"\$_entrypoint_function\"" \
|
|
748
|
+
" continue" \
|
|
749
|
+
" end" \
|
|
750
|
+
" # A release's own metadata and loader redefine the engine namespace on" \
|
|
751
|
+
" # every activation, including a switch to another release in this shell." \
|
|
752
|
+
" # Such a definition is not caller state when its provenance is a release" \
|
|
753
|
+
" # runtime file: this root's, the previous root's, or (sealed) any release" \
|
|
754
|
+
" # in the store. A same-named function from anywhere else stays guarded." \
|
|
755
|
+
" if builtin string match -q -r '^_?sp_fish_(loader|metadata)_' -- \"\$_entrypoint_function\"" \
|
|
756
|
+
" set -l _entrypoint_engine_source (builtin path resolve -- (builtin functions --details \"\$_entrypoint_function\") 2>/dev/null)" \
|
|
757
|
+
" set -l _entrypoint_engine_dir (builtin path dirname -- \"\$_entrypoint_engine_source\")" \
|
|
758
|
+
" set -l _entrypoint_engine_base (builtin path basename -- \"\$_entrypoint_engine_source\")" \
|
|
759
|
+
" if builtin contains -- \"\$_entrypoint_engine_base\" loader.fish metadata.fish" \
|
|
760
|
+
" if test \"\$_entrypoint_engine_dir\" = \"\$_entrypoint_expected_root/runtime/fish\"" \
|
|
761
|
+
" continue" \
|
|
762
|
+
" end" \
|
|
763
|
+
" if test -n \"\$_entrypoint_previous_root\"; and test \"\$_entrypoint_engine_dir\" = \"\$_entrypoint_previous_root/runtime/fish\"" \
|
|
764
|
+
" continue" \
|
|
765
|
+
" end" \
|
|
766
|
+
" if test \"\$_entrypoint_source_tree_mode\" != 1; and builtin string match -q -- '*/runtime/fish' \"\$_entrypoint_engine_dir\"" \
|
|
767
|
+
" set -l _entrypoint_engine_release (builtin path dirname -- (builtin path dirname -- \"\$_entrypoint_engine_dir\"))" \
|
|
768
|
+
" if test \"\$(builtin path dirname -- \"\$_entrypoint_engine_release\")\" = \"\$(builtin path dirname -- \"\$_entrypoint_expected_root\")\"" \
|
|
769
|
+
" continue" \
|
|
770
|
+
" end" \
|
|
771
|
+
" end" \
|
|
772
|
+
" end" \
|
|
773
|
+
" end" \
|
|
774
|
+
" set -l _entrypoint_source (builtin functions --details \"\$_entrypoint_function\")" \
|
|
775
|
+
" if not builtin contains -- \"\$_entrypoint_function\" \$_entrypoint_critical_names; and builtin string match -q -r '^(embedded:|autoloaded:|builtin)' -- \"\$_entrypoint_source\"" \
|
|
776
|
+
" continue" \
|
|
777
|
+
" end" \
|
|
778
|
+
" set -a _entrypoint_snapshot_names \"\$_entrypoint_function\"" \
|
|
779
|
+
" set -a _entrypoint_snapshot_definitions (builtin functions \"\$_entrypoint_function\" | string collect)" \
|
|
780
|
+
" set -a _entrypoint_snapshot_sources \"\$_entrypoint_source\"" \
|
|
781
|
+
" end" \
|
|
782
|
+
" # Introspecting a name materializes Fish 3's autoloadable-but-undefined" \
|
|
783
|
+
" # functions into functions --all --names, so the pre-loop snapshot is" \
|
|
784
|
+
" # stale by the time the body runs. Re-capture the diff baseline after the" \
|
|
785
|
+
" # snapshot loop and before sourcing; otherwise Fish's own system functions" \
|
|
786
|
+
" # would be published as entrypoint-owned with an unauthenticatable source." \
|
|
787
|
+
" set -l _entrypoint_before (builtin functions --all --names)" \
|
|
788
|
+
" set -l _entrypoint_source_helper __valise_fish_entrypoint_source_(builtin random)" \
|
|
789
|
+
" function \$_entrypoint_source_helper" \
|
|
790
|
+
" builtin source \"\$argv[1]\"" \
|
|
791
|
+
" return \$status" \
|
|
792
|
+
" end" \
|
|
793
|
+
" \$_entrypoint_source_helper \"\$_entrypoint_file\"" \
|
|
794
|
+
" set -l _entrypoint_status \$status" \
|
|
795
|
+
" builtin functions -e \$_entrypoint_source_helper 2>/dev/null" \
|
|
796
|
+
" set -l _entrypoint_after (builtin functions --all --names)" \
|
|
797
|
+
" set -l _entrypoint_created" \
|
|
798
|
+
" for _entrypoint_function in \$_entrypoint_after" \
|
|
799
|
+
" if not builtin contains -- \"\$_entrypoint_function\" \$_entrypoint_before" \
|
|
800
|
+
" set -a _entrypoint_created \"\$_entrypoint_function\"" \
|
|
801
|
+
" end" \
|
|
802
|
+
" end" \
|
|
803
|
+
" set -l _entrypoint_replaced" \
|
|
804
|
+
" set -l _entrypoint_snapshot_index 1" \
|
|
805
|
+
" for _entrypoint_original in \$_entrypoint_snapshot_names" \
|
|
806
|
+
" set -l _entrypoint_saved \"\$_entrypoint_snapshot_definitions[\$_entrypoint_snapshot_index]\"" \
|
|
807
|
+
" set -l _entrypoint_live (builtin functions \"\$_entrypoint_original\" | string collect)" \
|
|
808
|
+
" if not builtin functions -q \"\$_entrypoint_original\"; or not test \"\$_entrypoint_live\" = \"\$_entrypoint_saved\"" \
|
|
809
|
+
" set -a _entrypoint_replaced \"\$_entrypoint_original\"" \
|
|
810
|
+
" end" \
|
|
811
|
+
" set _entrypoint_snapshot_index (builtin math \$_entrypoint_snapshot_index + 1)" \
|
|
812
|
+
" end" \
|
|
813
|
+
" set -l _entrypoint_embedded_replaced" \
|
|
814
|
+
" set _entrypoint_snapshot_index 1" \
|
|
815
|
+
" for _entrypoint_original in \$_entrypoint_snapshot_names" \
|
|
816
|
+
" if builtin contains -- \"\$_entrypoint_original\" \$_entrypoint_replaced; and builtin string match -q 'embedded:*' -- \"\$_entrypoint_snapshot_sources[\$_entrypoint_snapshot_index]\"" \
|
|
817
|
+
" set _entrypoint_embedded_replaced \"\$_entrypoint_original\"" \
|
|
818
|
+
" break" \
|
|
819
|
+
" end" \
|
|
820
|
+
" set _entrypoint_snapshot_index (builtin math \$_entrypoint_snapshot_index + 1)" \
|
|
821
|
+
" end" \
|
|
822
|
+
" if test -n \"\$_entrypoint_embedded_replaced\"" \
|
|
823
|
+
" builtin printf 'valise Fish integration: embedded Fish function was mutated: %s\\n' \"\$_entrypoint_embedded_replaced\" >&2" \
|
|
824
|
+
" test \$_entrypoint_status -ne 0; or set _entrypoint_status 125" \
|
|
825
|
+
" end" \
|
|
826
|
+
" if not test \"\$_entrypoint_expected_root\" = \"\$SHELL_PROJECT_ROOT\"" \
|
|
827
|
+
" test \$_entrypoint_status -ne 0; or set _entrypoint_status 1" \
|
|
828
|
+
" end" \
|
|
829
|
+
" if not builtin set -q VALISE_FISH_READY; or not test (builtin count \$VALISE_FISH_READY) -eq 1; or not string match -qr '^1\$' -- \"\$VALISE_FISH_READY\"" \
|
|
830
|
+
" test \$_entrypoint_status -ne 0; or set _entrypoint_status 1" \
|
|
831
|
+
" end" \
|
|
832
|
+
" # An unverified source tree may run the real loader, so its own state" \
|
|
833
|
+
" # (anchors, roots, provider, loaded modules, loader ledger) is accepted" \
|
|
834
|
+
" # only when it is consistent with this root: anchors name this root's" \
|
|
835
|
+
" # runtime, roots lie under it, and every ledger entry is a live function" \
|
|
836
|
+
" # whose Fish provenance matches the recorded source under this root." \
|
|
837
|
+
" # The handshake, the hook-published ledgers, and any universal copy are" \
|
|
838
|
+
" # never legitimate after a source tree returns." \
|
|
839
|
+
" if test \$_entrypoint_source_tree_mode = 1" \
|
|
840
|
+
" set -l _entrypoint_forbidden_names _sp_fish_loader_bootstrap_mode _sp_fish_loader_bootstrap_seeds _sp_fish_loader_bootstrap_status _sp_fish_legacy_owned_exports _sp_fish_legacy_owned_sources _sp_fish_metadata_owned_exports _sp_fish_metadata_owned_sources _sp_fish_entrypoint_owned_exports _sp_fish_entrypoint_owned_sources" \
|
|
841
|
+
" set -l _entrypoint_loader_names _sp_fish_loader_expected_source _sp_fish_metadata_expected_source _sp_fish_loaded_modules _sp_fish_module_roots _sp_fish_metadata_provider _sp_fish_loader_owned_exports _sp_fish_loader_owned_sources" \
|
|
842
|
+
" set -l _entrypoint_protected_changed 0" \
|
|
843
|
+
" for _entrypoint_protected_name in \$_entrypoint_forbidden_names \$_entrypoint_loader_names" \
|
|
844
|
+
" if builtin set -q -U \"\$_entrypoint_protected_name\"" \
|
|
845
|
+
" set _entrypoint_protected_changed 1" \
|
|
846
|
+
" end" \
|
|
847
|
+
" end" \
|
|
848
|
+
" for _entrypoint_protected_name in \$_entrypoint_forbidden_names" \
|
|
849
|
+
" builtin set -q -g \"\$_entrypoint_protected_name\"; and set _entrypoint_protected_changed 1" \
|
|
850
|
+
" end" \
|
|
851
|
+
" set -l _entrypoint_root_prefix \"\$_entrypoint_expected_root/\"" \
|
|
852
|
+
" if builtin set -q -g _sp_fish_loader_expected_source; and not test \"\$_sp_fish_loader_expected_source\" = \"\$_entrypoint_expected_root/runtime/fish/loader.fish\"" \
|
|
853
|
+
" set _entrypoint_protected_changed 1" \
|
|
854
|
+
" end" \
|
|
855
|
+
" if builtin set -q -g _sp_fish_metadata_expected_source; and not test \"\$_sp_fish_metadata_expected_source\" = \"\$_entrypoint_expected_root/runtime/fish/metadata.fish\"" \
|
|
856
|
+
" set _entrypoint_protected_changed 1" \
|
|
857
|
+
" end" \
|
|
858
|
+
" for _entrypoint_module_root in \$_sp_fish_module_roots" \
|
|
859
|
+
" if not test \"\$_entrypoint_module_root\" = \"\$_entrypoint_expected_root\"; and not builtin string match -q -- \"\$_entrypoint_root_prefix*\" \"\$_entrypoint_module_root\"" \
|
|
860
|
+
" set _entrypoint_protected_changed 1" \
|
|
861
|
+
" end" \
|
|
862
|
+
" end" \
|
|
863
|
+
" if test -n \"\$_sp_fish_metadata_provider\"; and not builtin contains -- \"\$_sp_fish_metadata_provider\" \$_sp_fish_module_roots" \
|
|
864
|
+
" set _entrypoint_protected_changed 1" \
|
|
865
|
+
" end" \
|
|
866
|
+
" if test (builtin count \$_sp_fish_loaded_modules) -ne 0; and test (builtin count \$_sp_fish_module_roots) -eq 0" \
|
|
867
|
+
" set _entrypoint_protected_changed 1" \
|
|
868
|
+
" end" \
|
|
869
|
+
" if not test (builtin count \$_sp_fish_loader_owned_exports) -eq (builtin count \$_sp_fish_loader_owned_sources)" \
|
|
870
|
+
" set _entrypoint_protected_changed 1" \
|
|
871
|
+
" else" \
|
|
872
|
+
" set -l _entrypoint_ledger_index 1" \
|
|
873
|
+
" for _entrypoint_ledger_export in \$_sp_fish_loader_owned_exports" \
|
|
874
|
+
" set -l _entrypoint_ledger_source \"\$_sp_fish_loader_owned_sources[\$_entrypoint_ledger_index]\"" \
|
|
875
|
+
" if not builtin contains -- \"\$_entrypoint_ledger_export\" \$_entrypoint_created; or not builtin functions -q \"\$_entrypoint_ledger_export\"; or not test (builtin functions --details \"\$_entrypoint_ledger_export\") = \"\$_entrypoint_ledger_source\"; or not builtin string match -q -- \"\$_entrypoint_root_prefix*\" \"\$_entrypoint_ledger_source\"" \
|
|
876
|
+
" set _entrypoint_protected_changed 1" \
|
|
877
|
+
" end" \
|
|
878
|
+
" set _entrypoint_ledger_index (builtin math \$_entrypoint_ledger_index + 1)" \
|
|
879
|
+
" end" \
|
|
880
|
+
" end" \
|
|
881
|
+
" if test \$_entrypoint_protected_changed -ne 0" \
|
|
882
|
+
" for _entrypoint_protected_name in \$_entrypoint_forbidden_names \$_entrypoint_loader_names" \
|
|
883
|
+
" if builtin set -q -g \"\$_entrypoint_protected_name\"; and not builtin set -e -g \"\$_entrypoint_protected_name\"; builtin exit 125; end" \
|
|
884
|
+
" if builtin set -q -U \"\$_entrypoint_protected_name\"; and not builtin set -e -U \"\$_entrypoint_protected_name\"; builtin exit 125; end" \
|
|
885
|
+
" end" \
|
|
886
|
+
" test \$_entrypoint_status -ne 0; or set _entrypoint_status 1" \
|
|
887
|
+
" end" \
|
|
888
|
+
" end" \
|
|
889
|
+
" # The entrypoint is selected only after release verify authenticates its" \
|
|
890
|
+
" # immutable release. Its native metadata/loader state is therefore an" \
|
|
891
|
+
" # intentional result of authenticated activation, not caller mutation." \
|
|
892
|
+
" # Keep the exact caller-function and embedded-function checks above; those" \
|
|
893
|
+
" # are the custody boundary for this source transaction." \
|
|
894
|
+
" if test \$_entrypoint_status -ne 0; or test (builtin count \$_entrypoint_replaced) -ne 0" \
|
|
895
|
+
" for _entrypoint_function in \$_entrypoint_created" \
|
|
896
|
+
" if builtin functions -q \"\$_entrypoint_function\"" \
|
|
897
|
+
" builtin functions -e \"\$_entrypoint_function\"; or builtin exit 125" \
|
|
898
|
+
" end" \
|
|
899
|
+
" end" \
|
|
900
|
+
" if test (builtin count \$_entrypoint_replaced) -ne 0" \
|
|
901
|
+
" builtin printf '%s\\n' 'valise Fish integration: exact caller-function restoration is unavailable' >&2" \
|
|
902
|
+
" builtin exit 125" \
|
|
903
|
+
" end" \
|
|
904
|
+
" # A nested source can rewrite the handshake or the provenance anchors and" \
|
|
905
|
+
" # then return straight out of this transaction, past the adapter's own" \
|
|
906
|
+
" # checks. Clear the handshake and readiness and re-pin the anchors to" \
|
|
907
|
+
" # this root's runtime so nothing the failed source wrote survives." \
|
|
908
|
+
" for _entrypoint_state_name in VALISE_FISH_READY _sp_fish_loader_bootstrap_mode _sp_fish_loader_bootstrap_seeds _sp_fish_loader_bootstrap_status _sp_fish_loader_expected_source _sp_fish_metadata_expected_source" \
|
|
909
|
+
" if builtin set -q -g \"\$_entrypoint_state_name\"; and not builtin set -e -g \"\$_entrypoint_state_name\"; builtin exit 125; end" \
|
|
910
|
+
" if builtin set -q -U \"\$_entrypoint_state_name\"; and not builtin set -e -U \"\$_entrypoint_state_name\"; builtin exit 125; end" \
|
|
911
|
+
" end" \
|
|
912
|
+
" builtin set -g _sp_fish_loader_expected_source \"\$_entrypoint_expected_root/runtime/fish/loader.fish\"; or builtin exit 125" \
|
|
913
|
+
" builtin set -g _sp_fish_metadata_expected_source \"\$_entrypoint_expected_root/runtime/fish/metadata.fish\"; or builtin exit 125" \
|
|
914
|
+
" if test (builtin count \$_entrypoint_replaced) -ne 0; and test \$_entrypoint_status -eq 0" \
|
|
915
|
+
" set _entrypoint_status 1" \
|
|
916
|
+
" end" \
|
|
917
|
+
" return \$_entrypoint_status" \
|
|
918
|
+
" end" \
|
|
919
|
+
" # Publish only functions created by this authenticated entrypoint. The" \
|
|
920
|
+
" # source string is read back from Fish after sourcing; callers cannot" \
|
|
921
|
+
" # claim ownership by forging names or a parallel source ledger. Fish's" \
|
|
922
|
+
" # own system functions are not entrypoint state: a release that runs" \
|
|
923
|
+
" # completions materializes them, but their source is not an authenticated" \
|
|
924
|
+
" # release path, so publishing them would fail the next activation's ledger" \
|
|
925
|
+
" # check and its cleanup would erase real Fish functions. They stay in" \
|
|
926
|
+
" # _entrypoint_created so failure cleanup still removes the residue." \
|
|
927
|
+
" set -l _entrypoint_owned_exports" \
|
|
928
|
+
" set -l _entrypoint_owned_sources" \
|
|
929
|
+
" for _entrypoint_function in \$_entrypoint_created" \
|
|
930
|
+
" if not builtin functions -q \"\$_entrypoint_function\"" \
|
|
931
|
+
" builtin printf '%s\\n' 'valise Fish integration: created entrypoint function disappeared before ownership publication' >&2" \
|
|
932
|
+
" builtin exit 125" \
|
|
933
|
+
" end" \
|
|
934
|
+
" set -l _entrypoint_source (builtin functions --details \"\$_entrypoint_function\")" \
|
|
935
|
+
" if test -z \"\$_entrypoint_source\"" \
|
|
936
|
+
" builtin printf '%s\\n' 'valise Fish integration: created entrypoint function has no authenticated source' >&2" \
|
|
937
|
+
" builtin exit 125" \
|
|
938
|
+
" end" \
|
|
939
|
+
" switch \"\$_entrypoint_source\"" \
|
|
940
|
+
" case '/usr/share/fish/*' '/usr/local/share/fish/*' '/opt/local/share/fish/*' '/opt/homebrew/share/fish/*' 'embedded:completions/*' 'embedded:functions/*' 'autoloaded:*'" \
|
|
941
|
+
" continue" \
|
|
942
|
+
" end" \
|
|
943
|
+
" set -a _entrypoint_owned_exports \"\$_entrypoint_function\"" \
|
|
944
|
+
" set -a _entrypoint_owned_sources \"\$_entrypoint_source\"" \
|
|
945
|
+
" end" \
|
|
946
|
+
" builtin set -g _sp_fish_entrypoint_owned_exports \$_entrypoint_owned_exports; or builtin exit 125" \
|
|
947
|
+
" builtin set -g _sp_fish_entrypoint_owned_sources \$_entrypoint_owned_sources; or builtin exit 125" \
|
|
948
|
+
" return 0" \
|
|
949
|
+
" end" \
|
|
950
|
+
" builtin set -gx SHELL_PROJECT_ROOT \"\$_valise_fish_active_root\"" \
|
|
951
|
+
" \$_valise_fish_entrypoint_runner \"\$_valise_fish_active_root/runtime/fish/profile.fish\" \"\$_valise_fish_active_root\" \"\$_valise_fish_source_tree_mode\" \"\$_valise_fish_previous_root\"" \
|
|
952
|
+
" set -l _valise_fish_entrypoint_status \$status" \
|
|
953
|
+
" builtin functions -e \$_valise_fish_entrypoint_runner 2>/dev/null" \
|
|
954
|
+
" if test \$_valise_fish_entrypoint_status -ne 0" \
|
|
955
|
+
" if not builtin functions -q \$_valise_fish_owned_cleanup; or not builtin test (builtin functions \$_valise_fish_owned_cleanup | string collect) = \"\$_valise_fish_owned_cleanup_definition\"" \
|
|
956
|
+
" builtin printf '%s\\n' 'trusted ownership cleanup helper was modified' >&2" \
|
|
957
|
+
" builtin exit 125" \
|
|
958
|
+
" end" \
|
|
959
|
+
" \$_valise_fish_owned_cleanup" \
|
|
960
|
+
" if not builtin functions -q \$_valise_fish_root_restore_helper; or not builtin test (builtin functions \$_valise_fish_root_restore_helper | string collect) = \"\$_valise_fish_root_helper_definition\"" \
|
|
961
|
+
" builtin printf '%s\\n' 'trusted root restore helper was modified' >&2" \
|
|
962
|
+
" builtin exit 125" \
|
|
963
|
+
" end" \
|
|
964
|
+
" \$_valise_fish_root_restore_helper; or builtin exit 125" \
|
|
965
|
+
" return \$_valise_fish_entrypoint_status" \
|
|
966
|
+
" end" \
|
|
967
|
+
" if not builtin functions -q \$_valise_fish_success_cleanup_helper; or not builtin test (builtin functions \$_valise_fish_success_cleanup_helper | string collect) = \"\$_valise_fish_success_cleanup_helper_definition\"" \
|
|
968
|
+
" builtin printf '%s\\n' 'trusted success cleanup helper was modified' >&2" \
|
|
969
|
+
" builtin exit 125" \
|
|
970
|
+
" end" \
|
|
971
|
+
" \$_valise_fish_publish_active_helper; or builtin exit 125" \
|
|
972
|
+
" \$_valise_fish_success_cleanup_helper; or builtin exit 125" \
|
|
973
|
+
" return \$_valise_fish_entrypoint_status" \
|
|
974
|
+
"else" \
|
|
975
|
+
" # The release has no Fish runtime because its bundle has no Fish roots." \
|
|
976
|
+
" # Nothing loads; the shared success cleanup below keeps the hook silent" \
|
|
977
|
+
" # and leaves no helper behind." \
|
|
978
|
+
" :" \
|
|
979
|
+
"end" \
|
|
980
|
+
"if not builtin functions -q \$_valise_fish_success_cleanup_helper; or not builtin test (builtin functions \$_valise_fish_success_cleanup_helper | string collect) = \"\$_valise_fish_success_cleanup_helper_definition\"" \
|
|
981
|
+
" builtin printf '%s\\n' 'trusted success cleanup helper was modified' >&2" \
|
|
982
|
+
" builtin exit 125" \
|
|
983
|
+
"end" \
|
|
984
|
+
"\$_valise_fish_success_cleanup_helper; or builtin exit 125" \
|
|
985
|
+
"end"
|
|
986
|
+
}
|