Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mbedsys
bashopts
Commits
72fd4d7e
Commit
72fd4d7e
authored
Jun 30, 2018
by
Emeric Verschuur
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-enum' into 'master'
Fix enum See merge request
!8
parents
6bc701e4
f49c9a03
Pipeline
#104
passed with stage
in 12 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
CHANGELOG.md
CHANGELOG.md
+4
-0
VERSION
VERSION
+1
-1
bashopts.sh
bashopts.sh
+9
-6
No files found.
CHANGELOG.md
View file @
72fd4d7e
# Changelog
# Changelog
## 2.1.1
*
Fix enumeration type to support values with spaces
*
Improve join_by to support multi character separator
## 2.1.0
## 2.1.0
*
Improve the help display for big size values
*
Improve the help display for big size values
...
...
VERSION
View file @
72fd4d7e
2.
2.0
2.
1.1
bashopts.sh
View file @
72fd4d7e
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
set
-e
set
-e
BASHOPTS_VERSION
=
2.1.
0
BASHOPTS_VERSION
=
2.1.
1
bashopts_exit_handle
()
{
bashopts_exit_handle
()
{
local
err
=
$?
local
err
=
$?
...
@@ -256,7 +256,7 @@ bashopts_declare() {
...
@@ -256,7 +256,7 @@ bashopts_declare() {
-l
)
options[long_opt]
=
$1
;
shift
;;
-l
)
options[long_opt]
=
$1
;
shift
;;
-d
)
options[description]
=
$1
;
shift
;;
-d
)
options[description]
=
$1
;
shift
;;
-t
)
options[type]
=
$1
;
shift
;;
-t
)
options[type]
=
$1
;
shift
;;
-e
)
options_enum_values+
=(
$1
)
;
shift
;;
-e
)
options_enum_values+
=(
"
$1
"
)
;
shift
;;
-m
)
options[method]
=
$1
;
shift
;;
-m
)
options[method]
=
$1
;
shift
;;
-k
)
options[check]
=
$1
;
shift
;;
-k
)
options[check]
=
$1
;
shift
;;
-s
)
options[setting]
=
"true"
;;
-s
)
options[setting]
=
"true"
;;
...
@@ -280,7 +280,7 @@ bashopts_declare() {
...
@@ -280,7 +280,7 @@ bashopts_declare() {
if
[
${#
options_enum_values
[@]
}
-lt
2
]
;
then
if
[
${#
options_enum_values
[@]
}
-lt
2
]
;
then
bashopts_log C
"bashopts_declare:
${
options
[name]
}
enumeration need at least two elements (two '-e <val>' calls at least)"
bashopts_log C
"bashopts_declare:
${
options
[name]
}
enumeration need at least two elements (two '-e <val>' calls at least)"
fi
fi
options[enum_values]
=
"
$(
IFS
=
$'
\n
'
;
echo
"
${
options_enum_values
[
*
]
}
"
)
"
options[enum_values]
=
"
$(
printf
"%s
\n
"
"
${
options_enum_values
[
@
]
}
"
)
"
;;
;;
s|str|string
)
s|str|string
)
options[type]
=
"string"
options[type]
=
"string"
...
@@ -387,9 +387,12 @@ bashopts_math_min() {
...
@@ -387,9 +387,12 @@ bashopts_math_min() {
# join array element
# join array element
bashopts_join_by
()
{
bashopts_join_by
()
{
local
IFS
=
"
$1
"
local
sep
=
"
$1
"
shift
||
bashopts_log C
"Usage: bashopts_join_by <character> [elt1 [elt2...]]"
shift
||
bashopts_log C
"Usage: bashopts_join_by <separator> [elt1 [elt2...]]"
echo
"
$*
"
printf
"%s"
"
$1
"
test
$#
-gt
1
||
return
0
shift
printf
"
$sep
%s"
"
$@
"
}
}
# dump an option value by its name
# dump an option value by its name
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment