From: Jo-Philipp Wich Date: Tue, 15 Jul 2014 13:57:47 +0000 (+0200) Subject: jshn: do not collapse whitespace in json_load() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bd388d2b6c2c151bf513c1e449417d18ce02d10b;p=oweals%2Flibubox.git jshn: do not collapse whitespace in json_load() When running the test case below the $key variable holds "foo bar" instead of the expected "foo bar". -- 8< -- . /usr/share/libubox/jshn.sh json_init json_load '{ "key": "foo bar" }' json_get_var key key -- >8 -- Quote the output of the "jshn -r" backtick expression to prevent the shell from erroneously collapsing whitespace. Signed-off-by: Jo-Philipp Wich --- diff --git a/sh/jshn.sh b/sh/jshn.sh index 06ba965..5db1667 100644 --- a/sh/jshn.sh +++ b/sh/jshn.sh @@ -174,7 +174,7 @@ json_add_double() { # functions read access to json variables json_load() { - eval `jshn -r "$1"` + eval "`jshn -r "$1"`" } json_dump() {