-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
patches
executable file
·68 lines (47 loc) · 1.31 KB
/
patches
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
64
65
66
67
68
#!/usr/bin/env bash
# General tools for manipulating patches
# and dealing with patches.
# Returns the path used to look for a patch given a specific name.
__rvm_patch_lookup_path()
{
echo "/"
[[ -n "${rvm_patch_original_pwd:-""}" ]] && echo "$rvm_patch_original_pwd/"
echo "$PWD/"
__rvm_ruby_string_paths_under "$rvm_patches_path" | sed 's/$/\//' | sort -r
return $?
}
__rvm_expand_patch_name()
{
typeset name expanded_patch_name
name="${1:-""}"
[[ -z "$name" ]] && return 0
expanded_patch_name="$(rvm_ruby_string="${rvm_ruby_string}" "$rvm_scripts_path/patchsets" show "$name")"
if
[[ "$?" == "0" ]]
then
echo "${expanded_patch_name}"
elif
[[ "$name" != "default" ]]
then
echo "$name"
fi
return 0
}
# Return the full patch for a given patch.
__rvm_lookup_full_patch_path()
{
typeset extension patch_path directory directories
# Absolute path, pwd and then finally the rvm patches path.
directories=($(__rvm_patch_lookup_path))
for directory in "${directories[@]}" ; do
for extension in {"",.patch,.diff}; do
patch_path="${directory}${1}${extension}"
# -s reports directories too - so additional check -f needed
if [[ -s "$patch_path" && -f "$patch_path" ]]; then
echo "$patch_path"
return 0
fi
done
done
return 0
}