]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/ape/ls
crop /lib/face/48x48x8/n/nixie.1 to the right size (was 512x512)
[plan9front.git] / rc / bin / ape / ls
1 #!/bin/rc
2
3 # flags common to GNU and BSD ls
4
5 # -A    all except . and ..
6 # -C    force mc
7 # -F    usual
8 # -H    follow symlinks
9 # -L    follow symlinks
10 # -R    recursive list
11 # -U    unsorted (gnu)
12
13 # -a    include .files
14 # -c    show ctime
15 # -d    dirs
16 # -f    no sorting
17 # -l    long
18 # -p    put slash after dir (-F)
19 # -r    reverse
20 # -s    sizes
21 # -t    time sort
22 # -u    utime
23 # -1    single-column
24
25
26 flagfmt='A,C,F,H,L,R,U,a,c,d,f,l,p,r,s,t,u,1'
27 args='[file ...]'
28
29 if(! ifs=() eval `{aux/getflags $*}){
30         aux/usage
31         exit usage
32 }
33
34 fn fixlong {
35         echo total 1000
36         /$cputype/bin/sed 's/^(.).(.........) . [0-9]+ /\1\2 1 /'
37 }
38
39 post=cat
40
41 all=()
42 # ignore -A
43 if(~ $flagC 1) post=mc
44 if(~ $flagF 1) all=($all -F)
45 # ignore -H, -L
46 # save -R for later
47 if(~ $flagU 1) all=($all -n)
48 # ignore -a, -c
49 if(~ $flagd 1) all=($all -d)
50 if(~ $flagf 1) all=($all -n)
51 if(~ $flagl 1) { all=($all -l); post=fixlong }
52 if(~ $flagp 1) all=($all -F)
53 if(~ $flagr 1) all=($all -r)
54 if(~ $flags 1) all=($all -s)
55 if(~ $flagt 1) all=($all -t)
56 if(~ $flagu 1) all=($all -u)
57 # ignore -1
58
59 /$cputype/bin/ls $all $* | $post