aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/man/man.sh
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/man/man.sh')
-rwxr-xr-xusr.bin/man/man.sh35
1 files changed, 25 insertions, 10 deletions
diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index 18595042da5f..920223ce3c27 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -511,13 +511,21 @@ man_display_page_groff() {
# 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
+ local found_page has_slash locpath p path sect
# Check to see if it's a file. But only if it has a '/' in
- # the filename.
+ # the filename or if -l was specified.
case "$1" in
- */*) if [ -f "$1" -a -r "$1" ]; then
+ */*) has_slash=yes
+ ;;
+ esac
+ if [ -n "$has_slash" -o -n "$lflag" ]; then
+ if [ -f "$1" -a -r "$1" ]; then
decho "Found a usable page, displaying that"
+ if [ -z "$lflag" ]; then
+ echo "Opening a file directly is deprecated," \
+ "use -l instead." >&2
+ fi
unset use_cat
manpage="$1"
setup_cattool "$manpage"
@@ -531,9 +539,12 @@ man_find_and_display() {
man_display_page
fi
return
+ elif [ -n "$lflag" ]; then
+ echo "Cannot read $1" >&2
+ ret=1
+ return
fi
- ;;
- esac
+ fi
IFS=:
for sect in $MANSECT; do
@@ -601,7 +612,7 @@ man_parse_opts() {
local cmd_arg
OPTIND=1
- while getopts 'K:M:P:S:adfhkm:op:tw' cmd_arg; do
+ while getopts 'K:M:P:S:adfhklm:op:tw' cmd_arg; do
case "${cmd_arg}" in
K) Kflag=Kflag
REGEXP=$OPTARG ;;
@@ -613,6 +624,7 @@ man_parse_opts() {
f) fflag=fflag ;;
h) man_usage 0 ;;
k) kflag=kflag ;;
+ l) lflag=lflag ;;
m) mflag=$OPTARG ;;
o) oflag=oflag ;;
p) MANROFFSEQ=$OPTARG ;;
@@ -625,16 +637,19 @@ man_parse_opts() {
shift $(( $OPTIND - 1 ))
# Check the args for incompatible options.
-
- case "${Kflag}${fflag}${kflag}${tflag}${wflag}" in
+ case "${Kflag}${fflag}${kflag}${lflag}${tflag}${wflag}" in
Kflagfflag*) echo "Incompatible options: -K and -f"; man_usage ;;
Kflag*kflag*) echo "Incompatible options: -K and -k"; man_usage ;;
+ Kflag*lflag*) echo "Incompatible options: -K and -l"; man_usage ;;
Kflag*tflag) echo "Incompatible options: -K and -t"; man_usage ;;
fflagkflag*) echo "Incompatible options: -f and -k"; man_usage ;;
+ fflag*lflag*) echo "Incompatible options: -f and -l"; 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 ;;
+ *kflaglflag*) echo "Incompatible options: -k and -l"; man_usage ;;
+ *kflag*tflag*) echo "Incompatible options: -k and -t"; man_usage ;;
*kflag*wflag) echo "Incompatible options: -k and -w"; man_usage ;;
+ *lflag*wflag) echo "Incompatible options: -l and -w"; man_usage ;;
*tflagwflag) echo "Incompatible options: -t and -w"; man_usage ;;
esac
@@ -751,7 +766,7 @@ man_setup_locale() {
# Display usage for the man utility.
man_usage() {
echo 'Usage:'
- echo ' man [-adho] [-t | -w] [-M manpath] [-P pager] [-S mansect]'
+ echo ' man [-adhlo] [-t | -w] [-M manpath] [-P pager] [-S mansect]'
echo ' [-m arch[:machine]] [-p [eprtv]] [mansect] page [...]'
echo ' man -K | -f | -k expression [...] -- Search manual pages'