Plan 9 from Bell Labs’s /usr/web/sources/patch/sorry/ape-rc-scripts-safe-path/ls.orig

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/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

/$objtype/bin/ls $all $* | $post

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].