-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode
More file actions
63 lines (53 loc) · 1.79 KB
/
Copy pathcode
File metadata and controls
63 lines (53 loc) · 1.79 KB
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
60
61
62
63
#!/bin/bash
code() {
local target
local executable_path
local distro_name
local wsl_target
local windows_target
local remote_authority
local remote_uri
local uri_flag
if [ $# -eq 0 ]; then
code_print_help
return 0
fi
case "$1" in
-h|-help|--help)
code_print_help
return 0
;;
-i)
target="$(code_get_global_instructions_target)"
;;
*)
target="$1"
;;
esac
executable_path="$(code_get_insiders_executable_path)"
code_validate_executable_exists "$executable_path" || return $?
wsl_target="$(code_convert_target_to_wsl_path "$target")" || return $?
if [ ! -e "$wsl_target" ]; then
printf '%s\n' 'Using c to resolve path'
if c "$@" -c; then
return 0
fi
printf '%s\n' 'No path resolved; passing raw arguments to code'
code_launch_with_raw_arguments "$executable_path" "$@" || return $?
return 0
fi
if code_is_windows_mount_path "$wsl_target"; then
windows_target="$(code_convert_wsl_path_to_windows_path "$wsl_target")" || return $?
printf '%s\n' "$windows_target"
code_launch_with_windows_path "$executable_path" "$windows_target" || return $?
return 0
fi
distro_name="$(code_get_wsl_distro_name)" || return $?
remote_authority="$(code_build_remote_authority "$distro_name")"
wsl_target="$(code_ensure_path_has_leading_slash "$wsl_target")"
remote_uri="$(code_build_remote_uri "$remote_authority" "$wsl_target")"
uri_flag="$(code_choose_uri_flag_for_target "$target" "$wsl_target")"
printf '%s\n' "$remote_uri"
code_launch_with_uri "$executable_path" "$uri_flag" "$remote_uri" || return $?
return 0
}