Skip to content

Commit d20add3

Browse files
committed
fix empty arg assignment
1 parent b447f53 commit d20add3

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

lib/bashly/views/argument/validations.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ if [[ -n $(validate_<%= validation_function %> "$1") ]]; then
33
printf "<%= strings[:validation_error] %>\n" "<%= name.upcase %> $(validate_<%= validation_function %> "$1")"
44
exit 1
55
fi
6-
% end
6+
% end

lib/bashly/views/command/parse_requirements_case.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% if args.any?
33
% condition = "if"
44
% args.each do |arg|
5-
<%= condition %> [[ ! ${args[<%= arg.name %>]} ]]; then
5+
<%= condition %> [[ -z ${args[<%= arg.name %>]+x} ]]; then
66
<%= arg.render(:validations).indent 2 %>
77
args[<%= arg.name %>]=$1
88
shift

lib/bashly/views/flag/validations.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ if [[ -n $(validate_<%= validation_function %> "$2") ]]; then
33
printf "<%= strings[:validation_error] %>\n" "<%= usage_string %> $(validate_<%= validation_function %> "$2")"
44
exit 1
55
fi
6-
% end
6+
% end

spec/approvals/examples/empty-args

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ skipped src/initialize.sh (exists)
33
skipped src/test_command.sh (exists)
44
created ./cli
55
run ./cli --help to test your bash script
6+
+ ./cli test a b --flag c
7+
args:
8+
- ${args[--flag]} = c
9+
- ${args[optional_arg]} = b
10+
- ${args[required_arg]} = a
611
+ ./cli test ''
7-
# this file is located in 'src/test_command.sh'
8-
# code for 'cli test' goes here
9-
# you can edit it freely and regenerate (it will not be overwritten)
1012
args:
11-
- ${args[arg]} =
12-
+ ./cli test --flag ''
13-
# this file is located in 'src/test_command.sh'
14-
# code for 'cli test' goes here
15-
# you can edit it freely and regenerate (it will not be overwritten)
13+
- ${args[required_arg]} =
14+
+ ./cli test '' --flag ''
15+
args:
16+
- ${args[--flag]} =
17+
- ${args[required_arg]} =
18+
+ ./cli test '' '' --flag ''
1619
args:
1720
- ${args[--flag]} =
21+
- ${args[optional_arg]} =
22+
- ${args[required_arg]} =

0 commit comments

Comments
 (0)