Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-nodejs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-nodejs
Commits
9911a265
Unverified
Commit
9911a265
authored
Dec 18, 2018
by
Jeremy Morrell
Committed by
GitHub
Dec 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[kvstore] wrap string with spaces (#594)
* [kvstore] wrap string with spaces
parent
8469d24d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
kvstore.sh
lib/kvstore.sh
+11
-1
unit
test/unit
+10
-0
No files found.
lib/kvstore.sh
View file @
9911a265
...
...
@@ -19,6 +19,7 @@ kv_set() {
fi
}
# get the value, but don't unwrap quotes
kv_get
()
{
if
[[
$#
-eq
2
]]
;
then
local
f
=
$1
...
...
@@ -28,6 +29,15 @@ kv_get() {
fi
}
kv_get_escaped
()
{
local
value
=
$(
kv_get
$1
$2
$3
)
if
[[
$value
=
~
[[
:space:]]+
]]
;
then
echo
"
\"
$value
\"
"
else
echo
$value
fi
}
kv_keys
()
{
local
f
=
$1
local
keys
=()
...
...
@@ -47,7 +57,7 @@ kv_list() {
kv_keys
$f
|
tr
' '
'\n'
|
while
read
-r
key
;
do
if
[[
-n
$key
]]
;
then
echo
"
$key
=
$(
kv_get
$f
$key
)
"
echo
"
$key
=
$(
kv_get
_escaped
$f
$key
)
"
fi
done
}
test/unit
View file @
9911a265
...
...
@@ -108,6 +108,16 @@ testKeyValue() {
assertEquals
""
"
$(
kv_list
$store
)
"
}
testKeyValueEscaping
()
{
local
store
=
$(
mktemp
)
kv_create
$store
kv_set
$store
"key"
"value with a space"
assertEquals
"key=
\"
value with a space
\"
"
"
$(
kv_list
$store
)
"
assertEquals
"value with a space"
"
$(
kv_get
$store
"key"
)
"
}
# if the file doesn't exist, everything should be a no-op
testKeyValueNoFile
()
{
# empty file argument
...
...
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