initial commit, handles normal keys and prints full arrays
This commit is contained in:
25
tomcat
Executable file
25
tomcat
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# check usage
|
||||
if ! test -n "$1"; then
|
||||
printf "Usage: %s [resource...]\n" "$0" 1>&2
|
||||
exit 64 # sysexits(3) EX_USAGE
|
||||
fi
|
||||
|
||||
if ! test -e "$1"; then
|
||||
printf "%s: %s: No such file or directory.\n" "$0" "$1" 1>&2
|
||||
exit 66 # sysexits(3) EX_NOINPUT
|
||||
fi
|
||||
|
||||
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 '"[],')
|
||||
|
||||
printf "%s\n" "$VAL"
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user