about summary refs log tree commit diff
path: root/xls
diff options
context:
space:
mode:
authorclassabbyamp <void@placeviolette.net>2024-02-06 12:41:51 -0800
committerLeah Neukirchen <leah@vuxu.org>2024-02-07 23:50:27 +0100
commitee7c68cef40403cf654ecf4a8c55a348be28fd90 (patch)
treee7e6f0a64c74321bdbdefb70439bbf38e4619b21 /xls
parent45cf3ff916a551f42c6bcb2e2101042b58cd0ef8 (diff)
downloadxtools-ee7c68cef40403cf654ecf4a8c55a348be28fd90.tar.gz
xtools-ee7c68cef40403cf654ecf4a8c55a348be28fd90.tar.xz
xtools-ee7c68cef40403cf654ecf4a8c55a348be28fd90.zip
xls: show tree(1)-style output if called as xtree
Closes: #321 [via git-merge-pr]
Diffstat (limited to 'xls')
-rwxr-xr-xxls17
1 files changed, 15 insertions, 2 deletions
diff --git a/xls b/xls
index 3fdd090..08bdcca 100755
--- a/xls
+++ b/xls
@@ -1,5 +1,17 @@
-#!/bin/sh
+#!/bin/bash
 # xls PKGS... - list files contained in PKGS (including binpkgs)
+# xtree PKGS... - list files contained in PKGS (including binpkgs) in a tree-style format
+
+PROG="${0##*/}"
+FILTER="cat"
+
+if [ "$PROG" = xtree ]; then
+	if type tree >/dev/null; then
+		FILTER="tree --noreport --fflinks --fromfile ."
+	else
+		echo "$PROG: could not find tree, falling back to xls" >&2
+	fi
+fi
 
 BRANCH=$(git symbolic-ref -q --short HEAD 2>/dev/null)
 if [ -n "$XBPS_HOSTDIR" ]; then
@@ -21,6 +33,7 @@ ADDREPO="
 	--repository=$XBPS_BINPKGS/debug
 "
 
+set -o pipefail
 for pkg; do
-	xbps-query $ADDREPO -f $pkg
+	xbps-query $ADDREPO -f $pkg | $FILTER
 done