Skip to content

Commit d95c5de

Browse files
authored
Merge pull request #630 from vladriabtsev/master
avoid conflict with run() function with another bash frameworks
2 parents a3075a0 + 8fa881e commit d95c5de

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

lib/bashly/libraries/settings/settings.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,8 @@ var_aliases:
126126
other_args: ~
127127
deps: ~
128128
env_var_names: ~
129+
130+
# Choose different names for some of the internal functions.
131+
function_names:
132+
run: ~
133+
initialize: ~

lib/bashly/settings.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class << self
1515
:enable_inspect_args,
1616
:enable_sourcing,
1717
:enable_view_markers,
18+
:function_names,
1819
:lib_dir,
1920
:partials_extension,
2021
:private_reveal_key,
@@ -89,6 +90,14 @@ def full_lib_dir
8990
"#{source_dir}/#{lib_dir}"
9091
end
9192

93+
def function_name(key)
94+
function_names[key.to_s] || key.to_s
95+
end
96+
97+
def function_names
98+
@function_names ||= get :function_names
99+
end
100+
92101
def lib_dir
93102
@lib_dir ||= get :lib_dir
94103
end

lib/bashly/views/command/initialize.gtx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
= view_marker
22

3-
> initialize() {
3+
> {{ Settings.function_name :initialize }}() {
44
> declare -g version="<%= version %>"
55
> {{ Settings.strict_string }}
66

lib/bashly/views/command/master_script.gtx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
>
1616
if Settings.enabled? :sourcing
1717
> if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
18-
> initialize
19-
> run "$@"
18+
> {{ Settings.function_name :initialize }}
19+
> {{ Settings.function_name :run }} "$@"
2020
> fi
2121
else
22-
> initialize
23-
> run "$@"
22+
> {{ Settings.function_name :initialize }}
23+
> {{ Settings.function_name :run }} "$@"
2424
end
2525
>

lib/bashly/views/command/run.gtx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
= view_marker
22

3-
> run() {
3+
> {{ Settings.function_name :run }}() {
44
= render(:globals).indent(2)
55
>
66
> normalize_input "$@"

0 commit comments

Comments
 (0)