From f97eb82f134406e20d9e6ee428123ce0bb905654 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Mon, 15 Sep 2014 02:09:42 +0200 Subject: xq: strip colors, small refactor --- xq | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'xq') diff --git a/xq b/xq index 12c857f..29a1b48 100755 --- a/xq +++ b/xq @@ -1,15 +1,23 @@ #!/bin/sh # xq PKGS... - query information about XBPS package +rmcol() { + sed 's/\x1b\[[0-9;]*[mG]//g' +} + +totop() { + sed -n 's/^'"$1"'/&/p;tk;H;:k;${x;s/\n//;p};d' +} + BRANCH=$(git symbolic-ref -q --short HEAD 2>/dev/null) ADDREPO="--repository=hostdir/binpkgs/$BRANCH --repository=../hostdir/binpkgs/$BRANCH --repository=../../hostdir/binpkgs/$BRANCH" for pkg; do - xbps-query $ADDREPO -S "$pkg" | - sed -n 's/^short_desc/&/p;tk;H;:k;${x;s/\n//;p};d' | - sed -n 's/^pkgver/&/p;tk;H;:k;${x;s/\n//;p};d' + xbps-query $ADDREPO -S "$pkg" | rmcol | + totop short_desc | + totop pkgver xbps-query $ADDREPO -x "$pkg" | sed 's/^/ /;1s/^/depends:\n/' REVDEP=$(xbps-query -X "$pkg" | sed 's/^/ /' ) if [ "$REVDEP" ]; then -- cgit 1.4.1