diff --git a/ghc-info.sh b/ghc-info.sh index af1eabf..598faa2 100755 --- a/ghc-info.sh +++ b/ghc-info.sh @@ -1,8 +1,12 @@ #!/bin/sh -[ $# -lt 2 ] && echo "Usage: $(basename "$0") GHCVERSION INFOFIELD" +[ $# -lt 1 ] && echo "Usage: $(basename "$0") GHCVERSION INFOFIELD" && exit 1 -GHCVER=$1 -FIELD=$2 +GHCVER="$1" +FIELD="$2" -/usr/bin/ghc-${GHCVER} --info | grep \"$FIELD\" | sed -e 's/.*","\(.*\)")/\1/' +if [ -z "$FIELD" ]; then + /usr/bin/ghc-${GHCVER} --info | sed -e 's/.*(\(".*"\),\(".*"\).*/\1: \2/' -e '/]/d' +else + /usr/bin/ghc-${GHCVER} --info | grep \""$FIELD"\" | sed -e 's/.*","\(.*\)")/\1/' +fi