hacky array system
This commit is contained in:
parent
21dfb20e48
commit
36fd58b392
12
test.toml
Normal file
12
test.toml
Normal file
@ -0,0 +1,12 @@
|
||||
# full-line comment
|
||||
|
||||
[main] # appended comment
|
||||
key = "val"
|
||||
keyc = "val" # comment appended to key/value line
|
||||
"keyq" = "val"
|
||||
keycom = "# value with hash"
|
||||
|
||||
[fancy]
|
||||
arr = [ "val1", "val2", "val3" ]
|
||||
arrc = [ "val1", "val2", "val3", ] # comment appended to array line
|
||||
arrcom = [ "# one", "##two", "###three" ]
|
12
tomcat
12
tomcat
@ -18,8 +18,16 @@ TOML=$(sed 's/[^"#]#\+.*//g' <"$1")
|
||||
set -- $(printf "%s\n" "$2" | cut -d "." --output-delimiter=" " -f 1-)
|
||||
PAIRS=$(printf "%s\n" "$TOML" | awk "/^\[$1\]/{flag=1; next} /^\[/{flag=0} flag" - )
|
||||
|
||||
VAL=$(printf "%s\n" "$PAIRS" | sed -n "s/$2 *= *//p" | tr -d '"[],')
|
||||
ARR=$(printf "%s\n" "$2" | sed -n 's/.\+\[//p')
|
||||
|
||||
printf "%s\n" "$VAL"
|
||||
VAL=$(printf "%s\n" "$PAIRS" | sed -n "s/$2 *= *//p" | sed 's/, /,/g' | tr -d '[]')
|
||||
|
||||
if test -n "$ARR"; then
|
||||
set -- $(printf "%s\n" "$VAL" | cut -d "," --output-delimiter=" " -f 1-)
|
||||
POS=$(printf "%s\n" "$ARR" |tr -d ']')
|
||||
|
||||
else
|
||||
printf "%s\n" "$VAL"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user