003 File Manager
Current Path:
/usr/bin
usr
/
bin
/
📁
..
📄
CC
(82 B)
📄
Mail
(100.41 KB)
📄
addr2line
(90.26 KB)
📄
alias
(86 B)
📄
apply
(10.47 KB)
📄
apropos
(432.31 KB)
📄
ar
(49.81 KB)
📄
asa
(7.45 KB)
📄
asn1_compile
(110.05 KB)
📄
at
(28.09 KB)
📄
atq
(28.09 KB)
📄
atrm
(28.09 KB)
📄
awk
(211.45 KB)
📄
b64decode
(12.99 KB)
📄
b64encode
(8.38 KB)
📄
backlight
(11.23 KB)
📄
banner
(19.35 KB)
📄
basename
(8.55 KB)
📄
batch
(28.09 KB)
📄
bc
(237.73 KB)
📄
bg
(86 B)
📄
biff
(6.41 KB)
📄
brandelf
(10.69 KB)
📄
bsdcat
(10.27 KB)
📄
bsdcpio
(36.91 KB)
📄
bsdiff
(49.76 KB)
📄
bsdtar
(61.44 KB)
📄
bsnmpget
(77.14 KB)
📄
bsnmpset
(77.14 KB)
📄
bsnmpwalk
(77.14 KB)
📄
bspatch
(11.14 KB)
📄
bthost
(7 KB)
📄
btsockstat
(13.2 KB)
📄
bunzip2
(32.33 KB)
📄
byacc
(107.83 KB)
📄
bzcat
(32.33 KB)
📄
bzegrep
(4.08 KB)
📄
bzfgrep
(4.08 KB)
📄
bzgrep
(4.08 KB)
📄
bzip2
(32.33 KB)
📄
bzip2recover
(11.96 KB)
📄
bzless
(95 B)
📄
c++
(74.04 MB)
📄
c++filt
(339.13 KB)
📄
c89
(6.34 KB)
📄
c99
(7.66 KB)
📄
caesar
(9.42 KB)
📄
cal
(24.73 KB)
📄
calendar
(57.45 KB)
📄
cap_mkdb
(8.13 KB)
📄
cc
(74.04 MB)
📄
cd
(86 B)
📄
chat
(23.88 KB)
📄
chfn
(22.45 KB)
📄
chgrp
(10.23 KB)
📄
chkey
(12.55 KB)
📄
chpass
(22.45 KB)
📄
chsh
(22.45 KB)
📄
cksum
(11.41 KB)
📄
clang
(74.04 MB)
📄
clang++
(74.04 MB)
📄
clang-cpp
(74.04 MB)
📄
clang-tblgen
(1.42 MB)
📄
clear
(1.65 KB)
📄
cmp
(14.19 KB)
📄
col
(13.23 KB)
📄
colrm
(7.72 KB)
📄
column
(11.16 KB)
📄
comm
(8.81 KB)
📄
command
(86 B)
📄
compile_et
(26.34 KB)
📄
compress
(16.3 KB)
📄
cpio
(36.91 KB)
📄
cpp
(74.04 MB)
📄
cpuset
(12.83 KB)
📄
crontab
(33.41 KB)
📄
crunchgen
(34.34 KB)
📄
crunchide
(17.23 KB)
📄
crypt
(8.45 KB)
📄
csplit
(13.77 KB)
📄
ctags
(25.64 KB)
📄
ctfconvert
(106.35 KB)
📄
ctfdump
(23.53 KB)
📄
ctfmerge
(73.04 KB)
📄
ctlstat
(14.55 KB)
📄
cu
(64.88 KB)
📄
cut
(14.57 KB)
📄
dc
(237.73 KB)
📄
dialog
(55.78 KB)
📄
diff
(45.13 KB)
📄
diff3
(28.2 KB)
📄
dirname
(7.24 KB)
📄
dpv
(14.02 KB)
📄
drill
(61.59 KB)
📄
dtc
(221.17 KB)
📄
du
(12.29 KB)
📄
edit
(94.91 KB)
📄
ee
(94.91 KB)
📄
egrep
(27.91 KB)
📄
elfctl
(12.42 KB)
📄
elfdump
(25.74 KB)
📄
enigma
(8.45 KB)
📄
env
(14.63 KB)
📄
etdump
(11.88 KB)
📄
ex
(435.38 KB)
📄
expand
(8.03 KB)
📄
factor
(62.48 KB)
📄
false
(4.84 KB)
📄
fc
(86 B)
📄
fetch
(26.2 KB)
📄
fg
(86 B)
📄
fgrep
(27.91 KB)
📄
file
(22.76 KB)
📄
file2c
(7.32 KB)
📄
find
(54.46 KB)
📄
finger
(25.63 KB)
📄
flex
(334.37 KB)
📄
flex++
(334.37 KB)
📄
fmt
(14.74 KB)
📄
fold
(8.44 KB)
📄
fortune
(21.7 KB)
📄
from
(7.7 KB)
📄
fstat
(18.91 KB)
📄
fsync
(5.74 KB)
📄
ftp
(140.99 KB)
📄
fuser
(18.91 KB)
📄
gate-ftp
(140.99 KB)
📄
gcore
(19.5 KB)
📄
gcov
(3.53 MB)
📄
gencat
(13.18 KB)
📄
getaddrinfo
(14.95 KB)
📄
getconf
(19.45 KB)
📄
getent
(20.15 KB)
📄
getopt
(7.11 KB)
📄
getopts
(86 B)
📄
gprof
(32.22 KB)
📄
grdc
(11.18 KB)
📄
grep
(27.91 KB)
📄
groups
(13.22 KB)
📄
gunzip
(64.99 KB)
📄
gzcat
(64.99 KB)
📄
gzexe
(3.93 KB)
📄
gzip
(64.99 KB)
📄
hash
(86 B)
📄
hd
(29.89 KB)
📄
head
(10.32 KB)
📄
hexdump
(29.89 KB)
📄
host
(31 KB)
📄
hxtool
(79.49 KB)
📄
ibstat
(30.48 KB)
📄
ibv_asyncwatch
(8.2 KB)
📄
ibv_devices
(6.23 KB)
📄
ibv_devinfo
(17.64 KB)
📄
ibv_rc_pingpong
(23.69 KB)
📄
ibv_srq_pingpong
(23.83 KB)
📄
ibv_uc_pingpong
(20.84 KB)
📄
ibv_ud_pingpong
(21.32 KB)
📄
iconv
(11.91 KB)
📄
id
(13.22 KB)
📄
ident
(10.03 KB)
📄
indent
(45.82 KB)
📄
install
(30.84 KB)
📄
ipcrm
(13.15 KB)
📄
ipcs
(17.91 KB)
📄
iscsictl
(48.54 KB)
📄
jobs
(86 B)
📄
join
(13.92 KB)
📄
jot
(13.73 KB)
📄
kadmin
(79.09 KB)
📄
kcc
(36.52 KB)
📄
kdestroy
(9.39 KB)
📄
kdump
(52.53 KB)
📄
keylogin
(6.13 KB)
📄
keylogout
(5.72 KB)
📄
kf
(12.25 KB)
📄
kgetcred
(11.55 KB)
📄
killall
(13.93 KB)
📄
kinit
(24.53 KB)
📄
klist
(36.52 KB)
📄
kpasswd
(11.72 KB)
📄
krb5-config
(3.54 KB)
📄
ksu
(14.75 KB)
📄
kswitch
(36.52 KB)
📄
ktrace
(10.31 KB)
📄
ktrdump
(14.72 KB)
📄
kyua
(1.38 MB)
📄
lam
(10.34 KB)
📄
last
(16.6 KB)
📄
lastcomm
(12.56 KB)
📄
ld
(43.93 MB)
📄
ld.lld
(43.93 MB)
📄
ldd
(12.55 KB)
📄
ldd32
(9.27 KB)
📄
leave
(7.45 KB)
📄
less
(166.14 KB)
📄
lessecho
(8.27 KB)
📄
lesskey
(15.8 KB)
📄
lesspipe.sh
(389 B)
📄
lex
(334.37 KB)
📄
lex++
(334.37 KB)
📄
limits
(20.49 KB)
📄
lldb
(73.03 MB)
📄
lldb-tblgen
(623.26 KB)
📄
llvm-addr2line
(3.55 MB)
📄
llvm-ar
(10.5 MB)
📄
llvm-cov
(3.53 MB)
📄
llvm-cxxfilt
(339.13 KB)
📄
llvm-nm
(10.68 MB)
📄
llvm-objdump
(11.82 MB)
📄
llvm-profdata
(1.51 MB)
📄
llvm-ranlib
(10.5 MB)
📄
llvm-symbolizer
(3.55 MB)
📄
llvm-tblgen
(3 MB)
📄
locale
(17.29 KB)
📄
localedef
(85.9 KB)
📄
locate
(18.3 KB)
📄
lock
(11.27 KB)
📄
lockf
(8.84 KB)
📄
logger
(15.16 KB)
📄
login
(24.88 KB)
📄
logins
(10.73 KB)
📄
logname
(6.95 KB)
📄
look
(9.8 KB)
📄
lorder
(2.74 KB)
📄
lp
(2.66 KB)
📄
lpq
(33.75 KB)
📄
lpr
(39.14 KB)
📄
lprm
(31.5 KB)
📄
lsvfs
(7.65 KB)
📄
lzcat
(70.72 KB)
📄
lzdec
(10.55 KB)
📄
lzegrep
(4.08 KB)
📄
lzfgrep
(4.08 KB)
📄
lzgrep
(4.08 KB)
📄
lzless
(95 B)
📄
lzma
(70.72 KB)
📄
lzmainfo
(9.16 KB)
📄
m4
(68.2 KB)
📄
mail
(100.41 KB)
📄
mailq
(8.41 KB)
📄
mailx
(100.41 KB)
📄
make
(192.49 KB)
📄
make-roken
(14.34 KB)
📄
makewhatis
(432.31 KB)
📄
man
(21.79 KB)
📄
mandoc
(432.31 KB)
📄
manpath
(21.79 KB)
📄
mckey
(14.36 KB)
📄
mesg
(6.13 KB)
📄
minigzip
(10.16 KB)
📄
ministat
(25.14 KB)
📄
mkcsmapper
(28.7 KB)
📄
mkdep
(2.92 KB)
📄
mkesdb
(22.81 KB)
📄
mkfifo
(6.45 KB)
📄
mkimg
(50.36 KB)
📄
mkstr
(11.11 KB)
📄
mktemp
(7.79 KB)
📄
mkuzip
(20.43 KB)
📄
more
(166.14 KB)
📄
morse
(15.04 KB)
📄
msgs
(20.23 KB)
📄
mt
(26.32 KB)
📄
nawk
(211.45 KB)
📄
nc
(30.37 KB)
📄
ncal
(24.73 KB)
📄
netstat
(155.84 KB)
📄
newaliases
(8.41 KB)
📄
newgrp
(10.34 KB)
📄
newkey
(11.75 KB)
📄
nex
(435.38 KB)
📄
nfsstat
(25.2 KB)
📄
nice
(7.18 KB)
📄
nl
(11.48 KB)
📄
nm
(99.7 KB)
📄
nohup
(6.8 KB)
📄
ntpq
(301.71 KB)
📄
number
(9.13 KB)
📄
nvi
(435.38 KB)
📄
nview
(435.38 KB)
📄
objcopy
(120.88 KB)
📄
od
(29.89 KB)
📄
openssl
(637.82 KB)
📄
opieinfo
(6.74 KB)
📄
opiekey
(11.58 KB)
📄
opiepasswd
(13.88 KB)
📄
otp-md4
(11.58 KB)
📄
otp-md5
(11.58 KB)
📄
otp-sha1
(11.58 KB)
📄
pagesize
(1.7 KB)
📄
pargs
(46.16 KB)
📄
passwd
(9.32 KB)
📄
paste
(7.77 KB)
📄
patch
(57.34 KB)
📄
pathchk
(7.69 KB)
📄
penv
(46.16 KB)
📄
perror
(5.85 KB)
📄
pftp
(140.99 KB)
📄
pgrep
(18.38 KB)
📄
pkill
(18.38 KB)
📄
pmcstudy
(51.44 KB)
📄
pom
(10.15 KB)
📄
posixshmcontrol
(13.31 KB)
📄
pr
(27.27 KB)
📄
primes
(84.54 KB)
📄
printenv
(7.39 KB)
📄
printf
(14.13 KB)
📄
proccontrol
(8.14 KB)
📄
procstat
(46.16 KB)
📄
protect
(6.94 KB)
📄
pwdx
(46.16 KB)
📄
quota
(16.13 KB)
📄
random
(11.55 KB)
📄
ranlib
(49.81 KB)
📄
rctl
(13.92 KB)
📄
read
(86 B)
📄
readelf
(156.19 KB)
📄
readlink
(17.27 KB)
📄
ree
(94.91 KB)
📄
renice
(7.25 KB)
📄
reset
(19.5 KB)
📄
resizewin
(7.19 KB)
📄
rev
(6.73 KB)
📄
revoke
(5.49 KB)
📄
rfcomm_sppd
(14.71 KB)
📄
rgrep
(27.91 KB)
📄
rot13
(1.62 KB)
📄
rpcgen
(78.3 KB)
📄
rpcinfo
(25.75 KB)
📄
rping
(24.69 KB)
📄
rs
(13.56 KB)
📄
rup
(8.7 KB)
📄
ruptime
(10.38 KB)
📄
rusers
(9.28 KB)
📄
rwall
(9.23 KB)
📄
rwho
(9.37 KB)
📄
scp
(31.39 KB)
📄
script
(14.71 KB)
📄
sdiff
(24.23 KB)
📄
sed
(39.34 KB)
📄
seq
(12.32 KB)
📄
sftp
(76.2 KB)
📄
shar
(2.4 KB)
📄
showmount
(10 KB)
📄
size
(21.15 KB)
📄
slc
(40.04 KB)
📄
slogin
(198.23 KB)
📄
smbutil
(20.28 KB)
📄
sockstat
(22.31 KB)
📄
soelim
(8.45 KB)
📄
sort
(63.4 KB)
📄
split
(11.64 KB)
📄
sscop
(17.38 KB)
📄
ssh
(198.23 KB)
📄
ssh-add
(20.29 KB)
📄
ssh-agent
(27.74 KB)
📄
ssh-copy-id
(2.83 KB)
📄
ssh-keygen
(60.06 KB)
📄
ssh-keyscan
(21.52 KB)
📄
stat
(17.27 KB)
📄
stdbuf
(6.95 KB)
📄
strfile
(11.88 KB)
📄
string2key
(10.01 KB)
📄
strings
(15.95 KB)
📄
strip
(120.88 KB)
📄
su
(16.83 KB)
📄
sum
(11.41 KB)
📄
svnlite
(3.32 MB)
📄
svnliteadmin
(1.71 MB)
📄
svnlitebench
(2.58 MB)
📄
svnlitedumpfilter
(1.62 MB)
📄
svnlitefsfs
(1.53 MB)
📄
svnlitelook
(1.66 MB)
📄
svnlitemucc
(2.57 MB)
📄
svnliterdump
(2.6 MB)
📄
svnliteserve
(1.75 MB)
📄
svnlitesync
(2.01 MB)
📄
svnliteversion
(1.42 MB)
📄
systat
(103.04 KB)
📄
tabs
(10.98 KB)
📄
tail
(21.56 KB)
📄
talk
(24.45 KB)
📄
tar
(61.44 KB)
📄
tcopy
(10.21 KB)
📄
tee
(8.18 KB)
📄
telnet
(143.23 KB)
📄
tftp
(44.05 KB)
📄
time
(10.65 KB)
📄
timeout
(11.32 KB)
📄
tip
(64.88 KB)
📄
top
(68.98 KB)
📄
touch
(10.44 KB)
📄
tput
(8.66 KB)
📄
tr
(21.43 KB)
📄
true
(4.84 KB)
📄
truncate
(7.71 KB)
📄
truss
(141.34 KB)
📄
tset
(19.5 KB)
📄
tsort
(9.93 KB)
📄
tty
(5.7 KB)
📄
type
(86 B)
📄
ucmatose
(18.46 KB)
📄
udaddy
(18.08 KB)
📄
ul
(14.45 KB)
📄
ulimit
(86 B)
📄
umask
(86 B)
📄
unalias
(86 B)
📄
uname
(12.09 KB)
📄
uncompress
(16.3 KB)
📄
unexpand
(8.31 KB)
📄
unifdef
(34.22 KB)
📄
unifdefall
(2.11 KB)
📄
uniq
(12.65 KB)
📄
units
(18.03 KB)
📄
unlzma
(70.72 KB)
📄
unstr
(7.23 KB)
📄
unvis
(8.23 KB)
📄
unxz
(70.72 KB)
📄
unzip
(21.52 KB)
📄
unzstd
(126.04 KB)
📄
uptime
(18.29 KB)
📄
usbhidaction
(14.95 KB)
📄
usbhidctl
(14.4 KB)
📄
users
(11.56 KB)
📄
uudecode
(12.99 KB)
📄
uuencode
(8.38 KB)
📄
vacation
(97.79 KB)
📄
verify_krb5_conf
(21.38 KB)
📄
vi
(435.38 KB)
📄
view
(435.38 KB)
📄
vis
(9.53 KB)
📄
vmstat
(38.29 KB)
📄
vtfontcvt
(28.81 KB)
📄
w
(18.29 KB)
📄
wait
(86 B)
📄
wall
(13.77 KB)
📄
wc
(12.91 KB)
📄
what
(7.42 KB)
📄
whatis
(432.31 KB)
📄
whereis
(15.25 KB)
📄
which
(7.08 KB)
📄
who
(10.75 KB)
📄
whoami
(13.22 KB)
📄
whois
(14.84 KB)
📄
write
(13.38 KB)
📄
xargs
(17.41 KB)
📄
xo
(14.73 KB)
📄
xstr
(12.41 KB)
📄
xz
(70.72 KB)
📄
xzcat
(70.72 KB)
📄
xzdec
(10.55 KB)
📄
xzdiff
(3.13 KB)
📄
xzegrep
(4.08 KB)
📄
xzfgrep
(4.08 KB)
📄
xzgrep
(4.08 KB)
📄
xzless
(95 B)
📄
yacc
(107.83 KB)
📄
yes
(6.94 KB)
📄
ypcat
(7.39 KB)
📄
ypchfn
(22.45 KB)
📄
ypchpass
(22.45 KB)
📄
ypchsh
(22.45 KB)
📄
ypmatch
(7.48 KB)
📄
yppasswd
(9.32 KB)
📄
ypwhich
(13.8 KB)
📄
zcat
(64.99 KB)
📄
zcmp
(3.13 KB)
📄
zdiff
(3.13 KB)
📄
zegrep
(4.08 KB)
📄
zfgrep
(4.08 KB)
📄
zforce
(1.36 KB)
📄
zgrep
(4.08 KB)
📄
zinject
(27.63 KB)
📄
zless
(95 B)
📄
zmore
(1.97 KB)
📄
znew
(3.24 KB)
📄
zstd
(126.04 KB)
📄
zstdcat
(126.04 KB)
📄
zstdegrep
(4.08 KB)
📄
zstdfgrep
(4.08 KB)
📄
zstdgrep
(4.08 KB)
📄
zstdless
(95 B)
📄
zstdmt
(126.04 KB)
📄
zstream
(25.24 KB)
📄
zstreamdump
(29 B)
📄
ztest
(153.93 KB)
Editing: manpath
#! /bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2010 Gordon Tetlow # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # Usage: add_to_manpath path # Adds a variable to manpath while ensuring we don't have duplicates. # Returns true if we were able to add something. False otherwise. add_to_manpath() { case "$manpath" in *:$1) decho " Skipping duplicate manpath entry $1" 2 ;; $1:*) decho " Skipping duplicate manpath entry $1" 2 ;; *:$1:*) decho " Skipping duplicate manpath entry $1" 2 ;; *) if [ -d "$1" ]; then decho " Adding $1 to manpath" manpath="$manpath:$1" return 0 fi ;; esac return 1 } # Usage: build_manlocales # Builds a correct MANLOCALES variable. build_manlocales() { # If the user has set manlocales, who are we to argue. if [ -n "$MANLOCALES" ]; then return fi parse_configs # Trim leading colon MANLOCALES=${manlocales#:} decho "Available manual locales: $MANLOCALES" } # Usage: build_manpath # Builds a correct MANPATH variable. build_manpath() { local IFS # If the user has set a manpath, who are we to argue. if [ -n "$MANPATH" ]; then case "$MANPATH" in *:) PREPEND_MANPATH=${MANPATH} ;; :*) APPEND_MANPATH=${MANPATH} ;; *::*) PREPEND_MANPATH=${MANPATH%%::*} APPEND_MANPATH=${MANPATH#*::} ;; *) return ;; esac fi if [ -n "$PREPEND_MANPATH" ]; then IFS=: for path in $PREPEND_MANPATH; do add_to_manpath "$path" done unset IFS fi search_path decho "Adding default manpath entries" IFS=: for path in $man_default_path; do add_to_manpath "$path" done unset IFS parse_configs if [ -n "$APPEND_MANPATH" ]; then IFS=: for path in $APPEND_MANPATH; do add_to_manpath "$path" done unset IFS fi # Trim leading colon MANPATH=${manpath#:} decho "Using manual path: $MANPATH" } # Usage: check_cat catglob # Checks to see if a cat glob is available. check_cat() { if exists "$1"; then use_cat=yes catpage=$found setup_cattool $catpage decho " Found catpage $catpage" return 0 else return 1 fi } # Usage: check_man manglob catglob # Given 2 globs, figures out if the manglob is available, if so, check to # see if the catglob is also available and up to date. check_man() { if exists "$1"; then # We have a match, check for a cat page manpage=$found setup_cattool $manpage decho " Found manpage $manpage" if [ -n "${use_width}" ]; then # non-standard width unset use_cat decho " Skipping catpage: non-standard page width" elif exists "$2" && is_newer $found $manpage; then # cat page found and is newer, use that use_cat=yes catpage=$found setup_cattool $catpage decho " Using catpage $catpage" else # no cat page or is older unset use_cat decho " Skipping catpage: not found or old" fi return 0 fi return 1 } # Usage: decho "string" [debuglevel] # Echoes to stderr string prefaced with -- if high enough debuglevel. decho() { if [ $debug -ge ${2:-1} ]; then echo "-- $1" >&2 fi } # Usage: exists glob # Returns true if glob resolves to a real file. exists() { local IFS # Don't accidentally inherit callers IFS (breaks perl manpages) unset IFS # Use some globbing tricks in the shell to determine if a file # exists or not. set +f set -- "$1" $1 set -f if [ "$1" != "$2" -a -r "$2" ]; then found="$2" return 0 fi return 1 } # Usage: find_file path section subdir pagename # Returns: true if something is matched and found. # Search the given path/section combo for a given page. find_file() { local manroot catroot mann man0 catn cat0 manroot="$1/man$2" catroot="$1/cat$2" if [ -n "$3" ]; then manroot="$manroot/$3" catroot="$catroot/$3" fi if [ ! -d "$manroot" -a ! -d "$catroot" ]; then return 1 fi decho " Searching directory $manroot" 2 mann="$manroot/$4.$2*" man0="$manroot/$4.0*" catn="$catroot/$4.$2*" cat0="$catroot/$4.0*" # This is the behavior as seen by the original man utility. # Let's not change that which doesn't seem broken. if check_man "$mann" "$catn"; then return 0 elif check_man "$man0" "$cat0"; then return 0 elif check_cat "$catn"; then return 0 elif check_cat "$cat0"; then return 0 fi return 1 } # Usage: is_newer file1 file2 # Returns true if file1 is newer than file2 as calculated by mtime. is_newer() { if ! [ "$1" -ot "$2" ]; then decho " mtime: $1 not older than $2" 3 return 0 else decho " mtime: $1 older than $2" 3 return 1 fi } # Usage: manpath_parse_args "$@" # Parses commandline options for manpath. manpath_parse_args() { local cmd_arg while getopts 'Ldq' cmd_arg; do case "${cmd_arg}" in L) Lflag=Lflag ;; d) debug=$(( $debug + 1 )) ;; q) qflag=qflag ;; *) manpath_usage ;; esac done >&2 } # Usage: manpath_usage # Display usage for the manpath(1) utility. manpath_usage() { echo 'usage: manpath [-Ldq]' >&2 exit 1 } # Usage: manpath_warnings # Display some warnings to stderr. manpath_warnings() { if [ -n "$Lflag" -a -n "$MANLOCALES" ]; then echo "(Warning: MANLOCALES environment variable set)" >&2 fi } # Usage: man_check_for_so page path # Returns: True if able to resolve the file, false if it ended in tears. # Detects the presence of the .so directive and causes the file to be # redirected to another source file. man_check_for_so() { local IFS line tstr unset IFS if [ -n "$catpage" ]; then return 0 fi # We need to loop to accommodate multiple .so directives. while true do line=$($cattool $manpage | head -1) case "$line" in .so*) trim "${line#.so}" decho "$manpage includes $tstr" # Glob and check for the file. if ! check_man "$path/$tstr*" ""; then decho " Unable to find $tstr" return 1 fi ;; *) break ;; esac done return 0 } # Usage: man_display_page # Display either the manpage or catpage depending on the use_cat variable man_display_page() { local IFS pipeline testline # We are called with IFS set to colon. This causes really weird # things to happen for the variables that have spaces in them. unset IFS # If we are supposed to use a catpage and we aren't using troff(1) # just zcat the catpage and we are done. if [ -z "$tflag" -a -n "$use_cat" ]; then if [ -n "$wflag" ]; then echo "$catpage (source: $manpage)" ret=0 else if [ $debug -gt 0 ]; then decho "Command: $cattool $catpage | $MANPAGER" ret=0 else eval "$cattool $catpage | $MANPAGER" ret=$? fi fi return fi # Okay, we are using the manpage, do we just need to output the # name of the manpage? if [ -n "$wflag" ]; then echo "$manpage" ret=0 return fi if [ -n "$use_width" ]; then mandoc_args="-O width=${use_width}" fi testline="mandoc -Tlint -Wunsupp >/dev/null 2>&1" if [ -n "$tflag" ]; then pipeline="mandoc -Tps $mandoc_args" else pipeline="mandoc $mandoc_args | $MANPAGER" fi if ! eval "$cattool $manpage | $testline" ;then if which -s groff; then man_display_page_groff else echo "This manpage needs groff(1) to be rendered" >&2 echo "First install groff(1): " >&2 echo "pkg install groff " >&2 ret=1 fi return fi if [ $debug -gt 0 ]; then decho "Command: $cattool $manpage | $pipeline" ret=0 else eval "$cattool $manpage | $pipeline" ret=$? fi } # Usage: man_display_page_groff # Display the manpage using groff man_display_page_groff() { local EQN NROFF PIC TBL TROFF REFER VGRIND local IFS l nroff_dev pipeline preproc_arg tool # So, we really do need to parse the manpage. First, figure out the # device flag (-T) we have to pass to eqn(1) and groff(1). Then, # setup the pipeline of commands based on the user's request. # If the manpage is from a particular charset, we need to setup nroff # to properly output for the correct device. case "${manpage}" in *.${man_charset}/*) # I don't pretend to know this; I'm just copying from the # previous version of man(1). case "$man_charset" in KOI8-R) nroff_dev="koi8-r" ;; ISO8859-1) nroff_dev="latin1" ;; ISO8859-15) nroff_dev="latin1" ;; UTF-8) nroff_dev="utf8" ;; *) nroff_dev="ascii" ;; esac NROFF="$NROFF -T$nroff_dev" EQN="$EQN -T$nroff_dev" # Iff the manpage is from the locale and not just the charset, # then we need to define the locale string. case "${manpage}" in */${man_lang}_${man_country}.${man_charset}/*) NROFF="$NROFF -dlocale=$man_lang.$man_charset" ;; */${man_lang}.${man_charset}/*) NROFF="$NROFF -dlocale=$man_lang.$man_charset" ;; esac # Allow language specific calls to override the default # set of utilities. l=$(echo $man_lang | tr [:lower:] [:upper:]) for tool in EQN NROFF PIC TBL TROFF REFER VGRIND; do eval "$tool=\${${tool}_$l:-\$$tool}" done ;; *) NROFF="$NROFF -Tascii" EQN="$EQN -Tascii" ;; esac if [ -z "$MANCOLOR" ]; then NROFF="$NROFF -P-c" fi if [ -n "${use_width}" ]; then NROFF="$NROFF -rLL=${use_width}n -rLT=${use_width}n" fi if [ -n "$MANROFFSEQ" ]; then set -- -$MANROFFSEQ while getopts 'egprtv' preproc_arg; do case "${preproc_arg}" in e) pipeline="$pipeline | $EQN" ;; g) ;; # Ignore for compatibility. p) pipeline="$pipeline | $PIC" ;; r) pipeline="$pipeline | $REFER" ;; t) pipeline="$pipeline | $TBL" ;; v) pipeline="$pipeline | $VGRIND" ;; *) usage ;; esac done # Strip the leading " | " from the resulting pipeline. pipeline="${pipeline#" | "}" else pipeline="$TBL" fi if [ -n "$tflag" ]; then pipeline="$pipeline | $TROFF" else pipeline="$pipeline | $NROFF | $MANPAGER" fi if [ $debug -gt 0 ]; then decho "Command: $cattool $manpage | $pipeline" ret=0 else eval "$cattool $manpage | $pipeline" ret=$? fi } # Usage: man_find_and_display page # Search through the manpaths looking for the given page. man_find_and_display() { local found_page locpath p path sect # Check to see if it's a file. But only if it has a '/' in # the filename. case "$1" in */*) if [ -f "$1" -a -r "$1" ]; then decho "Found a usable page, displaying that" unset use_cat manpage="$1" setup_cattool $manpage if man_check_for_so $manpage $(dirname $manpage); then found_page=yes man_display_page fi return fi ;; esac IFS=: for sect in $MANSECT; do decho "Searching section $sect" 2 for path in $MANPATH; do for locpath in $locpaths; do p=$path/$locpath p=${p%/.} # Rid ourselves of the trailing /. # Check if there is a MACHINE specific manpath. if find_file $p $sect $MACHINE "$1"; then if man_check_for_so $manpage $p; then found_page=yes man_display_page if [ -n "$aflag" ]; then continue 2 else return fi fi fi # Check if there is a MACHINE_ARCH # specific manpath. if find_file $p $sect $MACHINE_ARCH "$1"; then if man_check_for_so $manpage $p; then found_page=yes man_display_page if [ -n "$aflag" ]; then continue 2 else return fi fi fi # Check plain old manpath. if find_file $p $sect '' "$1"; then if man_check_for_so $manpage $p; then found_page=yes man_display_page if [ -n "$aflag" ]; then continue 2 else return fi fi fi done done done unset IFS # Nothing? Well, we are done then. if [ -z "$found_page" ]; then echo "No manual entry for $1" >&2 ret=1 return fi } # Usage: man_parse_args "$@" # Parses commandline options for man. man_parse_args() { local IFS cmd_arg while getopts 'M:P:S:adfhkm:op:tw' cmd_arg; do case "${cmd_arg}" in M) MANPATH=$OPTARG ;; P) MANPAGER=$OPTARG ;; S) MANSECT=$OPTARG ;; a) aflag=aflag ;; d) debug=$(( $debug + 1 )) ;; f) fflag=fflag ;; h) man_usage 0 ;; k) kflag=kflag ;; m) mflag=$OPTARG ;; o) oflag=oflag ;; p) MANROFFSEQ=$OPTARG ;; t) tflag=tflag ;; w) wflag=wflag ;; *) man_usage ;; esac done >&2 shift $(( $OPTIND - 1 )) # Check the args for incompatible options. case "${fflag}${kflag}${tflag}${wflag}" in fflagkflag*) echo "Incompatible options: -f and -k"; man_usage ;; fflag*tflag*) echo "Incompatible options: -f and -t"; man_usage ;; fflag*wflag) echo "Incompatible options: -f and -w"; man_usage ;; *kflagtflag*) echo "Incompatible options: -k and -t"; man_usage ;; *kflag*wflag) echo "Incompatible options: -k and -w"; man_usage ;; *tflagwflag) echo "Incompatible options: -t and -w"; man_usage ;; esac # Short circuit for whatis(1) and apropos(1) if [ -n "$fflag" ]; then do_whatis "$@" exit fi if [ -n "$kflag" ]; then do_apropos "$@" exit fi IFS=: for sect in $man_default_sections; do if [ "$sect" = "$1" ]; then decho "Detected manual section as first arg: $1" MANSECT="$1" shift break fi done unset IFS pages="$*" } # Usage: man_setup # Setup various trivial but essential variables. man_setup() { # Setup machine and architecture variables. if [ -n "$mflag" ]; then MACHINE_ARCH=${mflag%%:*} MACHINE=${mflag##*:} fi if [ -z "$MACHINE_ARCH" ]; then MACHINE_ARCH=$($SYSCTL -n hw.machine_arch) fi if [ -z "$MACHINE" ]; then MACHINE=$($SYSCTL -n hw.machine) fi decho "Using architecture: $MACHINE_ARCH:$MACHINE" setup_pager # Setup manual sections to search. if [ -z "$MANSECT" ]; then MANSECT=$man_default_sections fi decho "Using manual sections: $MANSECT" build_manpath man_setup_locale man_setup_width } # Usage: man_setup_width # Set up page width. man_setup_width() { local sizes unset use_width case "$MANWIDTH" in [0-9]*) if [ "$MANWIDTH" -gt 0 2>/dev/null ]; then use_width=$MANWIDTH fi ;; [Tt][Tt][Yy]) if { sizes=$($STTY size 0>&3 2>/dev/null); } 3>&1; then set -- $sizes if [ $2 -gt 80 ]; then use_width=$(($2-2)) fi fi ;; esac if [ -n "$use_width" ]; then decho "Using non-standard page width: ${use_width}" else decho 'Using standard page width' fi } # Usage: man_setup_locale # Setup necessary locale variables. man_setup_locale() { local lang_cc local locstr locpaths='.' man_charset='US-ASCII' # Setup locale information. if [ -n "$oflag" ]; then decho 'Using non-localized manpages' else # Use the locale tool to give us proper locale information eval $( $LOCALE ) if [ -n "$LANG" ]; then locstr=$LANG else locstr=$LC_CTYPE fi case "$locstr" in C) ;; C.UTF-8) ;; POSIX) ;; [a-z][a-z]_[A-Z][A-Z]\.*) lang_cc="${locstr%.*}" man_lang="${locstr%_*}" man_country="${lang_cc#*_}" man_charset="${locstr#*.}" locpaths="$locstr" locpaths="$locpaths:$man_lang.$man_charset" if [ "$man_lang" != "en" ]; then locpaths="$locpaths:en.$man_charset" fi locpaths="$locpaths:." ;; *) echo 'Unknown locale, assuming C' >&2 ;; esac fi decho "Using locale paths: $locpaths" } # Usage: man_usage [exitcode] # Display usage for the man utility. man_usage() { echo 'Usage:' echo ' man [-adho] [-t | -w] [-M manpath] [-P pager] [-S mansect]' echo ' [-m arch[:machine]] [-p [eprtv]] [mansect] page [...]' echo ' man -f page [...] -- Emulates whatis(1)' echo ' man -k page [...] -- Emulates apropos(1)' # When exit'ing with -h, it's not an error. exit ${1:-1} } # Usage: parse_configs # Reads the end-user adjustable config files. parse_configs() { local IFS file files if [ -n "$parsed_configs" ]; then return fi unset IFS # Read the global config first in case the user wants # to override config_local. if [ -r "$config_global" ]; then parse_file "$config_global" fi # Glob the list of files to parse. set +f files=$(echo $config_local) set -f for file in $files; do if [ -r "$file" ]; then parse_file "$file" fi done parsed_configs='yes' } # Usage: parse_file file # Reads the specified config files. parse_file() { local file line tstr var file="$1" decho "Parsing config file: $file" while read line; do decho " $line" 2 case "$line" in \#*) decho " Comment" 3 ;; MANPATH*) decho " MANPATH" 3 trim "${line#MANPATH}" add_to_manpath "$tstr" ;; MANLOCALE*) decho " MANLOCALE" 3 trim "${line#MANLOCALE}" manlocales="$manlocales:$tstr" ;; MANCONFIG*) decho " MANCONFIG" 3 trim "${line#MANCONFIG}" config_local="$tstr" ;; # Set variables in the form of FOO_BAR *_*[\ \ ]*) var="${line%%[\ \ ]*}" trim "${line#$var}" eval "$var=\"$tstr\"" decho " Parsed $var" 3 ;; esac done < "$file" } # Usage: search_path # Traverse $PATH looking for manpaths. search_path() { local IFS p path decho "Searching PATH for man directories" IFS=: for path in $PATH; do if add_to_manpath "$path/man"; then : elif add_to_manpath "$path/MAN"; then : else case "$path" in */bin) p="${path%/bin}/share/man" add_to_manpath "$p" p="${path%/bin}/man" add_to_manpath "$p" ;; esac fi done unset IFS if [ -z "$manpath" ]; then decho ' Unable to find any manpaths, using default' manpath=$man_default_path fi } # Usage: search_whatis cmd [arglist] # Do the heavy lifting for apropos/whatis search_whatis() { local IFS bad cmd f good key keywords loc opt out path rval wlist cmd="$1" shift whatis_parse_args "$@" build_manpath build_manlocales setup_pager if [ "$cmd" = "whatis" ]; then opt="-w" fi f='whatis' IFS=: for path in $MANPATH; do if [ \! -d "$path" ]; then decho "Skipping non-existent path: $path" 2 continue fi if [ -f "$path/$f" -a -r "$path/$f" ]; then decho "Found whatis: $path/$f" wlist="$wlist $path/$f" fi for loc in $MANLOCALES; do if [ -f "$path/$loc/$f" -a -r "$path/$loc/$f" ]; then decho "Found whatis: $path/$loc/$f" wlist="$wlist $path/$loc/$f" fi done done unset IFS if [ -z "$wlist" ]; then echo "$cmd: no whatis databases in $MANPATH" >&2 exit 1 fi rval=0 for key in $keywords; do out=$(grep -Ehi $opt -- "$key" $wlist) if [ -n "$out" ]; then good="$good\\n$out" else bad="$bad\\n$key: nothing appropriate" rval=1 fi done # Strip leading carriage return. good=${good#\\n} bad=${bad#\\n} if [ -n "$good" ]; then echo -e "$good" | $MANPAGER fi if [ -n "$bad" ]; then echo -e "$bad" >&2 fi exit $rval } # Usage: setup_cattool page # Finds an appropriate decompressor based on extension setup_cattool() { case "$1" in *.bz) cattool='/usr/bin/bzcat' ;; *.bz2) cattool='/usr/bin/bzcat' ;; *.gz) cattool='/usr/bin/zcat' ;; *.lzma) cattool='/usr/bin/lzcat' ;; *.xz) cattool='/usr/bin/xzcat' ;; *) cattool='/usr/bin/zcat -f' ;; esac } # Usage: setup_pager # Correctly sets $MANPAGER setup_pager() { # Setup pager. if [ -z "$MANPAGER" ]; then if [ -n "$MANCOLOR" ]; then MANPAGER="less -sR" else if [ -n "$PAGER" ]; then MANPAGER="$PAGER" else MANPAGER="less -s" fi fi fi decho "Using pager: $MANPAGER" } # Usage: trim string # Trims whitespace from beginning and end of a variable trim() { tstr=$1 while true; do case "$tstr" in [\ \ ]*) tstr="${tstr##[\ \ ]}" ;; *[\ \ ]) tstr="${tstr%%[\ \ ]}" ;; *) break ;; esac done } # Usage: whatis_parse_args "$@" # Parse commandline args for whatis and apropos. whatis_parse_args() { local cmd_arg while getopts 'd' cmd_arg; do case "${cmd_arg}" in d) debug=$(( $debug + 1 )) ;; *) whatis_usage ;; esac done >&2 shift $(( $OPTIND - 1 )) keywords="$*" } # Usage: whatis_usage # Display usage for the whatis/apropos utility. whatis_usage() { echo "usage: $cmd [-d] keyword [...]" exit 1 } # Supported commands do_apropos() { [ $(stat -f %i /usr/bin/man) -ne $(stat -f %i /usr/bin/apropos) ] && \ exec apropos "$@" search_whatis apropos "$@" } do_man() { man_parse_args "$@" if [ -z "$pages" ]; then echo 'What manual page do you want?' >&2 exit 1 fi man_setup for page in $pages; do decho "Searching for $page" man_find_and_display "$page" done exit ${ret:-0} } do_manpath() { manpath_parse_args "$@" if [ -z "$qflag" ]; then manpath_warnings fi if [ -n "$Lflag" ]; then build_manlocales echo $MANLOCALES else build_manpath echo $MANPATH fi exit 0 } do_whatis() { [ $(stat -f %i /usr/bin/man) -ne $(stat -f %i /usr/bin/whatis) ] && \ exec whatis "$@" search_whatis whatis "$@" } # User's PATH setting decides on the groff-suite to pick up. EQN=eqn NROFF='groff -S -P-h -Wall -mtty-char -man' PIC=pic REFER=refer TBL=tbl TROFF='groff -S -man' VGRIND=vgrind LOCALE=/usr/bin/locale STTY=/bin/stty SYSCTL=/sbin/sysctl debug=0 man_default_sections='1:8:2:3:3lua:n:4:5:6:7:9:l' man_default_path='/usr/share/man:/usr/share/openssl/man:/usr/local/share/man:/usr/local/man' cattool='/usr/bin/zcat -f' config_global='/etc/man.conf' # This can be overridden via a setting in /etc/man.conf. config_local='/usr/local/etc/man.d/*.conf' # Set noglobbing for now. I don't want spurious globbing. set -f case "$0" in *apropos) do_apropos "$@" ;; *manpath) do_manpath "$@" ;; *whatis) do_whatis "$@" ;; *) do_man "$@" ;; esac
Upload File
Create Folder