]> gitweb.fluxo.info Git - keyringer.git/commitdiff
keyringer_tree fixed on FreeBSD; also, prettier everywhere else
authorrysiek <rysiek@example.org>
Fri, 3 Nov 2017 12:36:42 +0000 (10:36 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 3 Nov 2017 12:36:42 +0000 (10:36 -0200)
lib/keyringer/actions/tree

index 7bf173d1e5163ff83ae2f027af179c8ab6f4582d..a87754877af86d7e009bf6c4c0fd02016a44f530 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Thanks http://www.centerkey.com/tree/
 function keyringer_tree {
-  ls -R $* | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
+  find $* | sed -e 's/[^-][^\/]*\//|  /g' | sed -r -e 's/\|  ([^|])/|- \1/'
 }
 
 # Load functions
@@ -19,6 +19,11 @@ CWD="`pwd`"
 shift
 ARGS="`echo "$*" | sed -e "s|^/*||"`"
 
+# on *BSD, find expects at least one argument with the path
+if [ "$ARGS" == "" ]; then
+  ARGS="./"
+fi
+
 # Check implementation
 if which tree &> /dev/null; then
   TREE="tree"