From 09ba6c764406d1d52c024bc59a2f875f7643b7ce Mon Sep 17 00:00:00 2001 From: emma Date: Tue, 8 Nov 2022 01:00:01 -0500 Subject: [PATCH] tab-delineated arrays when no index is specified --- tomcat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tomcat b/tomcat index 7298ef0..ed6b3dd 100755 --- a/tomcat +++ b/tomcat @@ -38,19 +38,19 @@ fi VAL=$(printf "%s\n" "$TOML" |\ # output only lines between TABLE and the next table awk "/^\[$TABLE\]/{flag=1; next} /^\[/{flag=0} flag" - |\ - # remove the key from the string and concatenate arrays, removing + # remove the key from the string and delineate arrays, removing # brackets, trailing commas, and leading spaces - sed -n "s/$KEY *= *//p" | sed 's/", "/","/g' | tr -d '[]' |\ + sed -n "s/$KEY *= *//p" | sed 's/", "/ /g' | tr -d '[]"' |\ sed 's/, *$//g' | sed 's/^ *//g') # test if ARR is set; if it is, then we have an array index to grab if test -n "$ARR"; then # change the line delineator to newlines for parsing and output the result - printf "%s\n" "$VAL" | sed 's/",/"\n/g' | tr -d '"' | head -n "$ARR" |\ + printf "%s\n" "$VAL" | sed 's/ /\n/g' | head -n "$ARR" |\ tail -n 1 else # remove quotes and output VAL - printf "%s\n" "$VAL" | tr -d '"' + printf "%s\n" "$VAL" fi exit 0