-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlc.es
39 lines (36 loc) · 1.11 KB
/
lc.es
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/local/bin/es
options = $options lc
# lc.es -- convenience for plan 9 users
fn lc {
catch @ e { } {
let( true = <={true} ; false = <={false}
line-output = $false
stream-output = $false
sort-files = $true
helpme = $false
ofiles = ''
files = *
sortedfiles = '') {
sortedfiles = `{ { for(i = $files) { echo $i } } | sort }
for(x = $*){
if {~ $x '-m' } { stream-output = $true ; break }
if {~ $x '-C' } { line-output = $true ; break }
if {~ $x '-f' } { sort-files = $false }
if {~ $x '-h' } { helpme = $true ; break }
}
if {~ $helpme $true } {
echo 'usage: lc -[f] -[mCh]'
echo ' f -- do not sort filenames'
echo ' C -- no column output'
echo ' m -- stream output'
echo ' h -- show this message'
return 0
}
if {~ $sort-files $true} { ofiles = $sortedfiles } { ofiles = $files }
if {~ $line-output $true} { for(i = $ofiles) { echo $i } ; return 0 }
if {~ $stream-output $true} { for(i = $ofiles) { echo -n $i ; echo -n ', ' }; echo '' ; return 0 }
# otherwise print out a block of files
echo $ofiles
}
}
}