From 110ffae47db27a49bbc43f86ba3737bccc1b3085 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 26 Jan 2013 23:58:22 +0100 Subject: o Rewriting most of this stuff to make it feel more like git. --- libexec/app-cat-conf | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 libexec/app-cat-conf (limited to 'libexec/app-cat-conf') diff --git a/libexec/app-cat-conf b/libexec/app-cat-conf new file mode 100755 index 0000000..78d3c36 --- /dev/null +++ b/libexec/app-cat-conf @@ -0,0 +1,47 @@ +#!/bin/bash + +if [[ $APPSH_HOME == "" ]] +then + APPSH_HOME=`dirname "$0"` + APPSH_HOME=`cd "$APPSH_HOME/.." && pwd` +fi + +set -e + +key_expr="[a-zA-Z][_a-zA-Z0-9]*" + +file=.app/config + +while getopts "f:n:" opt +do + case $opt in + f) + file=$OPTARG + ;; + n) + name=$OPTARG + ;; + \?) + echo "Invalid option: $OPTARG" >&2 + exit 1 + ;; + esac +done + +if [ -z "$name" ] +then + filter="s,^[ ]*\($key_expr\.$key_expr\)[ ]*=[ ]*\(.*\)$,\1=\2,p" +else + filter="s,^\($name\)=\(.*\),\1=\2,p" +fi + +if [[ $APPSH_DEFAULT_CONFIG == "" ]] +then + APPSH_DEFAULT_CONFIG=$APPSH_HOME/lib/default-config +fi + +# The awk script makes sure each key only appears once +cat "$file" "$APPSH_DEFAULT_CONFIG" | \ + sed -n -e "$filter" $extra | \ + awk -F = ' (!($1 in a)){a[$1]; print }' | \ + sort -- cgit v1.2.3