summaryrefslogtreecommitdiff
path: root/rc/bin/ape/ls
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 17:14:36 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 17:14:36 +0300
commit2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f (patch)
treef6343b1ce11a8c87251dd27cf3d3e26b50693fa7 /rc/bin/ape/ls
parente463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (diff)
Import sources from 2011-03-30 iso image - rc
Diffstat (limited to 'rc/bin/ape/ls')
-rwxr-xr-xrc/bin/ape/ls59
1 files changed, 59 insertions, 0 deletions
diff --git a/rc/bin/ape/ls b/rc/bin/ape/ls
new file mode 100755
index 000000000..eef7d0962
--- /dev/null
+++ b/rc/bin/ape/ls
@@ -0,0 +1,59 @@
+#!/bin/rc
+
+# flags common to GNU and BSD ls
+
+# -A all except . and ..
+# -C force mc
+# -F usual
+# -H follow symlinks
+# -L follow symlinks
+# -R recursive list
+# -U unsorted (gnu)
+#
+# -a include .files
+# -c show ctime
+# -d dirs
+# -f no sorting
+# -l long
+# -p put slash after dir (-F)
+# -r reverse
+# -s sizes
+# -t time sort
+# -u utime
+# -1 single-column
+
+
+flagfmt='A,C,F,H,L,R,U,a,c,d,f,l,p,r,s,t,u,1'
+args='[file ...]'
+
+if(! ifs=() eval `{aux/getflags $*}){
+ aux/usage
+ exit usage
+}
+
+fn fixlong {
+ echo total 1000
+ /$cputype/bin/sed 's/^(.).(.........) . [0-9]+ /\1\2 1 /'
+}
+
+post=cat
+
+all=()
+# ignore -A
+if(~ $flagC 1) post=mc
+if(~ $flagF 1) all=($all -F)
+# ignore -H, -L
+# save -R for later
+if(~ $flagU 1) all=($all -n)
+# ignore -a, -c
+if(~ $flagd 1) all=($all -d)
+if(~ $flagf 1) all=($all -n)
+if(~ $flagl 1) { all=($all -l); post=fixlong }
+if(~ $flagp 1) all=($all -F)
+if(~ $flagr 1) all=($all -r)
+if(~ $flags 1) all=($all -s)
+if(~ $flagt 1) all=($all -t)
+if(~ $flagu 1) all=($all -u)
+# ignore -1
+
+/$cputype/bin/ls $all $* | $post