5 |
# Source file position: <groff-source>/contrib/groffer/groffer2.sh |
# Source file position: <groff-source>/contrib/groffer/groffer2.sh |
6 |
# Installed position: <prefix>/lib/groff/groffer/groffer2.sh |
# Installed position: <prefix>/lib/groff/groffer/groffer2.sh |
7 |
|
|
8 |
|
# This file should not be run independently. It is called by |
9 |
|
# `groffer.sh' in the source or by the installed `groffer' program. |
10 |
|
|
11 |
# Copyright (C) 2001,2002,2003,2004,2005 |
# Copyright (C) 2001,2002,2003,2004,2005 |
12 |
# Free Software Foundation, Inc. |
# Free Software Foundation, Inc. |
13 |
# Written by Bernd Warken |
# Written by Bernd Warken |
14 |
|
|
15 |
# Last update: 30 July 2005 |
# Last update: 2 August 2005 |
16 |
|
|
17 |
# This file is part of groffer, which is part of groff. |
# This file is part of `groffer', which is part of `groff'. |
18 |
|
|
19 |
# groff is free software; you can redistribute it and/or modify it |
# `groff' is free software; you can redistribute it and/or modify it |
20 |
# under the terms of the GNU General Public License as published by |
# under the terms of the GNU General Public License as published by |
21 |
# the Free Software Foundation; either version 2, or (at your option) |
# the Free Software Foundation; either version 2, or (at your option) |
22 |
# any later version. |
# any later version. |
23 |
|
|
24 |
# groff is distributed in the hope that it will be useful, but WITHOUT |
# `groff' is distributed in the hope that it will be useful, but |
25 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
26 |
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
27 |
# License for more details. |
# General Public License for more details. |
28 |
|
|
29 |
# You should have received a copy of the GNU General Public License |
# You should have received a copy of the GNU General Public License |
30 |
# along with groff; see the files COPYING and LICENSE in the top |
# along with `groff'; see the files COPYING and LICENSE in the top |
31 |
# directory of the groff source. If not, write to the Free Software |
# directory of the `groff' source. If not, write to the Free Software |
32 |
# Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. |
# Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, |
33 |
|
# USA. |
34 |
|
|
35 |
|
|
36 |
######################################################################## |
######################################################################## |
37 |
# diagnostic messages |
# diagnostic messages for debugging |
38 |
# |
# |
39 |
export _DEBUG; |
export _DEBUG; |
40 |
_DEBUG='no'; # disable debugging information |
_DEBUG='no'; # disable debugging information |
46 |
|
|
47 |
export _DEBUG_KEEP_FILES; |
export _DEBUG_KEEP_FILES; |
48 |
_DEBUG_KEEP_FILES='no' # disable file keeping in temporary dir |
_DEBUG_KEEP_FILES='no' # disable file keeping in temporary dir |
49 |
_DEBUG_KEEP_FILES='yes' # enable file keeping in temporary dir |
#_DEBUG_KEEP_FILES='yes' # enable file keeping in temporary dir |
50 |
|
|
51 |
|
export _DEBUG_PRINT_PARAMS; |
52 |
|
_DEBUG_PRINT_PARAMS='no'; # disable printing of all parameters |
53 |
|
#_DEBUG_PRINT_PARAMS='yes'; # enable printing of all parameters |
54 |
|
|
55 |
|
export _DEBUG_PRINT_SHELL; |
56 |
|
_DEBUG_PRINT_SHELL='no'; # disable printing of the shell name |
57 |
|
#_DEBUG_PRINT_SHELL='yes'; # enable printing of the shell name |
58 |
|
|
59 |
|
|
60 |
# test of $* on --debug |
# test of $GROFFER_OPT and $* on `--debug' with shortest abbreviation `--deb' |
61 |
case " $* " in |
case " ${GROFFER_OPT} $* " in |
62 |
*' --debug '*) |
*' --deb '*|*' --debu '*|*' --debug '*) |
63 |
_DEBUG='yes'; |
_DEBUG='yes'; |
64 |
_DEBUG_LM='yes'; |
_DEBUG_LM='yes'; |
65 |
_DEBUG_KEEP_FILES='yes'; |
_DEBUG_KEEP_FILES='yes'; |
66 |
|
_DEBUG_PRINT_PARAMS='yes'; |
67 |
|
_DEBUG_PRINT_SHELL='yes'; |
68 |
;; |
;; |
69 |
esac; |
esac; |
70 |
|
|
71 |
|
if test _"${_DEBUG_PRINT_PARAMS}"_ = _yes_ |
72 |
|
then |
73 |
|
echo "parameters: ${GROFFER_OPT} $@" >&2; |
74 |
|
fi; |
75 |
|
|
76 |
|
if test _"${_DEBUG_PRINT_SHELL}"_ = _yes_ |
77 |
|
then |
78 |
|
if test _"${_SHELL}"_ = __ |
79 |
|
then |
80 |
|
if test _"${POSIXLY_CORRECT}"_ = _y_ |
81 |
|
then |
82 |
|
echo 'shell: bash as /bin/sh (none specified)' >&2; |
83 |
|
else |
84 |
|
echo 'shell: /bin/sh (none specified)' >&2; |
85 |
|
fi; |
86 |
|
else |
87 |
|
echo "shell: ${_SHELL}" >&2; |
88 |
|
fi; |
89 |
|
fi; |
90 |
|
|
91 |
|
|
92 |
######################################################################## |
######################################################################## |
93 |
# Environment Variables |
# Environment Variables |
112 |
# read-only variables (global to this file) |
# read-only variables (global to this file) |
113 |
######################################################################## |
######################################################################## |
114 |
|
|
|
# characters |
|
|
|
|
|
export _SPACE; |
|
|
export _SQUOTE; |
|
|
export _TAB; |
|
|
|
|
|
_SPACE=' '; |
|
|
_SQUOTE="'"; |
|
|
_TAB=' '; |
|
|
|
|
115 |
# function return values; `0' means ok; other values are error codes |
# function return values; `0' means ok; other values are error codes |
116 |
export _ALL_EXIT; |
export _ALL_EXIT; |
117 |
export _BAD; |
export _BAD; |
125 |
_BAD='1'; # return negatively, error code `1' |
_BAD='1'; # return negatively, error code `1' |
126 |
_ERROR='7'; # for syntax errors; no `-1' in `ash' |
_ERROR='7'; # for syntax errors; no `-1' in `ash' |
127 |
|
|
128 |
_ALL_EXIT="${_GOOD} ${_BAD} ${_ERROR}"; # all exit codes (for `trap_set') |
# all exit codes (for `trap_set()') |
129 |
|
_ALL_EXIT="${_GOOD} ${_BAD} ${_ERROR}"; |
130 |
|
|
131 |
_NO="${_BAD}"; |
_NO="${_BAD}"; |
132 |
_YES="${_GOOD}"; |
_YES="${_GOOD}"; |
164 |
export _VIEWER_HTML_X; # viewer program for html mode in X |
export _VIEWER_HTML_X; # viewer program for html mode in X |
165 |
export _VIEWER_HTML_TTY; # viewer program for html mode in tty |
export _VIEWER_HTML_TTY; # viewer program for html mode in tty |
166 |
_VIEWER_DVI='kdvi,xdvi,dvilx'; |
_VIEWER_DVI='kdvi,xdvi,dvilx'; |
167 |
_VIEWER_PDF='kghostview,ggv,xpdf,acroread,kpdf'; |
_VIEWER_PDF='kghostview --scale 1.45,ggv,xpdf,acroread,kpdf'; |
168 |
_VIEWER_PS='kghostview,ggv,gv,ghostview,gs_x11,gs'; |
_VIEWER_PS='kghostview --scale 1.45,ggv,gv,ghostview,gs_x11,gs'; |
169 |
_VIEWER_HTML='konqueror,mozilla,netscape,opera,amaya,arena,lynx'; |
_VIEWER_HTML='konqueror,mozilla,netscape,opera,amaya,arena,lynx'; |
170 |
_VIEWER_X='gxditview,xditview'; |
_VIEWER_X='gxditview,xditview'; |
171 |
|
|
226 |
_OPTS_GROFFER_SHORT_NA="'h' 'Q' 'v' 'V' 'X' 'Z'"; |
_OPTS_GROFFER_SHORT_NA="'h' 'Q' 'v' 'V' 'X' 'Z'"; |
227 |
_OPTS_GROFFER_SHORT_ARG="'T'"; |
_OPTS_GROFFER_SHORT_ARG="'T'"; |
228 |
|
|
229 |
_OPTS_GROFFER_LONG_NA="'auto' 'debug' 'default' 'dvi' \ |
_OPTS_GROFFER_LONG_NA="'auto' 'debug' 'default' 'do-nothing' 'dvi' \ |
230 |
'groff' 'help' 'intermediate-output' 'html' 'man' \ |
'groff' 'help' 'intermediate-output' 'html' 'man' \ |
231 |
'no-location' 'no-man' 'pdf' 'ps' 'rv' 'source' 'text' 'text-device' \ |
'no-location' 'no-man' 'pdf' 'ps' 'rv' 'source' 'text' 'text-device' \ |
232 |
'title' 'tty' 'tty-device' 'version' 'whatis' 'where' 'www' 'x' 'X'"; |
'title' 'tty' 'tty-device' 'version' 'whatis' 'where' 'www' 'x' 'X'"; |
254 |
_OPTS_X_LONG_NA="'iconic' 'rv'"; |
_OPTS_X_LONG_NA="'iconic' 'rv'"; |
255 |
|
|
256 |
_OPTS_X_LONG_ARG="'background' 'bd' 'bg' 'bordercolor' 'borderwidth' \ |
_OPTS_X_LONG_ARG="'background' 'bd' 'bg' 'bordercolor' 'borderwidth' \ |
257 |
'bw' 'display' 'fg' 'fn' 'font' 'foreground' 'ft', 'geometry' |
'bw' 'display' 'fg' 'fn' 'font' 'foreground' 'ft' 'geometry' \ |
258 |
'resolution' 'title' 'xrm'"; |
'resolution' 'title' 'xrm'"; |
259 |
|
|
260 |
###### groffer options inherited from man |
###### groffer options inherited from man |
262 |
_OPTS_MAN_SHORT_NA=""; |
_OPTS_MAN_SHORT_NA=""; |
263 |
_OPTS_MAN_SHORT_ARG=""; |
_OPTS_MAN_SHORT_ARG=""; |
264 |
|
|
265 |
_OPTS_MAN_LONG_NA="'all' 'ascii' 'catman' 'debug' 'ditroff' 'help' \ |
_OPTS_MAN_LONG_NA="'all' 'ascii' 'catman' 'ditroff' \ |
266 |
'local-file' 'location' 'pager' 'troff' 'update' 'version' \ |
'local-file' 'location' 'troff' 'update'"; |
|
'whatis' 'where'"; |
|
267 |
|
|
268 |
_OPTS_MAN_LONG_ARG="'extension' 'locale' 'manpath' \ |
_OPTS_MAN_LONG_ARG="'locale' 'manpath' \ |
269 |
'pager' 'preprocessor' 'prompt' 'sections' 'systems' 'troff-device'"; |
'pager' 'preprocessor' 'prompt' 'sections' 'systems' 'troff-device'"; |
270 |
|
|
271 |
###### additional options for parsing $MANOPT only |
###### additional options for parsing $MANOPT only |
275 |
_OPTS_MANOPT_SHORT_ARG="'e' 'L' 'm' 'M' 'p' 'P' 'r' 'S' 'T'"; |
_OPTS_MANOPT_SHORT_ARG="'e' 'L' 'm' 'M' 'p' 'P' 'r' 'S' 'T'"; |
276 |
|
|
277 |
_OPTS_MANOPT_LONG_NA="${_OPTS_MAN_LONG_NA} \ |
_OPTS_MANOPT_LONG_NA="${_OPTS_MAN_LONG_NA} \ |
278 |
'apropos' 'debug' 'default' 'html' 'ignore-case' 'location-cat' \ |
'apropos' 'debug' 'default' 'help' 'html' 'ignore-case' 'location-cat' \ |
279 |
'match-case' 'troff' 'update' 'version' 'where-cat'"; |
'match-case' 'troff' 'update' 'version' 'whatis' 'where' 'where-cat'"; |
280 |
|
|
281 |
_OPTS_MANOPT_LONG_ARG="${_OPTS_MAN_LONG_NA} \ |
_OPTS_MANOPT_LONG_ARG="${_OPTS_MAN_LONG_NA} \ |
282 |
'config_file' 'encoding' 'locale'"; |
'config_file' 'encoding' 'extension' 'locale'"; |
283 |
|
|
284 |
###### collections of command line options |
###### collections of command line options |
285 |
|
|
286 |
_OPTS_CMDLINE_SHORT_NA="${_OPTS_GROFFER_SHORT_NA}\ |
_OPTS_CMDLINE_SHORT_NA="${_OPTS_GROFFER_SHORT_NA} \ |
287 |
${_OPTS_GROFF_SHORT_NA} ${_OPTS_X_SHORT_NA} ${_OPTS_MAN_SHORT_NA}"; |
${_OPTS_GROFF_SHORT_NA} ${_OPTS_X_SHORT_NA} ${_OPTS_MAN_SHORT_NA}"; |
288 |
_OPTS_CMDLINE_SHORT_ARG="${_OPTS_GROFFER_SHORT_ARG} \ |
_OPTS_CMDLINE_SHORT_ARG="${_OPTS_GROFFER_SHORT_ARG} \ |
289 |
${_OPTS_GROFF_SHORT_ARG} ${_OPTS_X_SHORT_ARG} ${_OPTS_MAN_SHORT_ARG}"; |
${_OPTS_GROFF_SHORT_ARG} ${_OPTS_X_SHORT_ARG} ${_OPTS_MAN_SHORT_ARG}"; |
298 |
# read-write variables (global to this file) |
# read-write variables (global to this file) |
299 |
######################################################################## |
######################################################################## |
300 |
|
|
301 |
|
export _ALL_PARAMS; # All options and file name parameters |
302 |
export _ADDOPTS_GROFF; # Transp. options for groff (`eval'). |
export _ADDOPTS_GROFF; # Transp. options for groff (`eval'). |
303 |
export _ADDOPTS_POST; # Transp. options postproc (`eval'). |
export _ADDOPTS_POST; # Transp. options postproc (`eval'). |
304 |
export _ADDOPTS_X; # Transp. options X postproc (`eval'). |
export _ADDOPTS_X; # Transp. options X postproc (`eval'). |
371 |
export _OPT_WHATIS; # print the one-liner man info |
export _OPT_WHATIS; # print the one-liner man info |
372 |
export _OPT_XRM; # specify X resource. |
export _OPT_XRM; # specify X resource. |
373 |
export _OPT_Z; # groff option -Z. |
export _OPT_Z; # groff option -Z. |
374 |
# _TMP_* temporary files |
# _TMP_* temporary directory and files |
375 |
export _TMP_DIR; # groffer directory for temporary files |
export _TMP_DIR; # groffer directory for temporary files |
376 |
export _TMP_CAT; # stores concatenation of everything |
export _TMP_CAT; # stores concatenation of everything |
377 |
export _TMP_STDIN; # stores stdin, if any |
export _TMP_STDIN; # stores stdin, if any |
385 |
|
|
386 |
|
|
387 |
######################################################################## |
######################################################################## |
388 |
|
# Test of `unset' |
389 |
|
# |
390 |
|
export _UNSET; |
391 |
|
export _foo; |
392 |
|
_foo=bar; |
393 |
|
_res="$(unset _foo 2>&1)"; |
394 |
|
if unset _foo >${_NULL_DEV} 2>&1 && \ |
395 |
|
test _"${_res}"_ = __ && test _"${_foo}"_ = __ |
396 |
|
then |
397 |
|
_UNSET='unset'; |
398 |
|
eval "${_UNSET}" _res; |
399 |
|
else |
400 |
|
_UNSET=':'; |
401 |
|
fi; |
402 |
|
|
403 |
|
|
404 |
|
######################################################################## |
405 |
# Test of `test'. |
# Test of `test'. |
406 |
# |
# |
407 |
test "a" = "a" || exit 1; |
if test a = a && test a != b && test -f "${_GROFFER_SH}" |
408 |
|
then |
409 |
|
:; |
410 |
|
else |
411 |
|
echo '"test" did not work.' >&2; |
412 |
|
exit "${_ERROR}"; |
413 |
|
fi; |
414 |
|
|
415 |
|
|
416 |
######################################################################## |
######################################################################## |
417 |
# Test of `echo' and the `$()' construct. |
# Test of `echo' and the `$()' construct. |
418 |
# |
# |
419 |
echo '' >${_NULL_DEV} || exit "${_ERROR}"; |
if echo '' >${_NULL_DEV} |
420 |
|
then |
421 |
|
:; |
422 |
|
else |
423 |
|
echo '"echo" did not work.' >&2; |
424 |
|
exit "${_ERROR}"; |
425 |
|
fi; |
426 |
if test _"$(t1="$(echo te)" && |
if test _"$(t1="$(echo te)" && |
427 |
t2="$(echo '')" && |
t2="$(echo '')" && |
428 |
t3="$(echo 'st')" && |
t3="$(echo 'st')" && |
429 |
echo "${t1}${t2}${t3}")"_ \ |
echo "${t1}${t2}${t3}")"_ \ |
430 |
!= _test_; |
!= _test_ |
431 |
then |
then |
432 |
|
echo 'The "$()" construct did not work' >&2; |
433 |
exit "${_ERROR}"; |
exit "${_ERROR}"; |
434 |
fi; |
fi; |
435 |
|
|
442 |
return "${_OK}"; |
return "${_OK}"; |
443 |
} |
} |
444 |
|
|
445 |
if _t_e_s_t_f_u_n_c_ 2>${_NULL_DEV}; |
if _t_e_s_t_f_u_n_c_ 2>${_NULL_DEV} |
446 |
then |
then |
447 |
: |
:; |
448 |
else |
else |
449 |
echo 'shell does not support function definitions.' >&2; |
echo 'Shell '"${_SHELL}"' does not support function definitions.' >&2; |
450 |
exit "${_ERROR}"; |
exit "${_ERROR}"; |
451 |
fi; |
fi; |
452 |
|
|
456 |
######################################################################## |
######################################################################## |
457 |
|
|
458 |
|
|
459 |
|
export _START_DIR; # directory at start time of the script |
460 |
|
_START_DIR="$(pwd)"; |
461 |
|
|
462 |
# For variables that can be reset by option `--default', see reset(). |
# For variables that can be reset by option `--default', see reset(). |
463 |
|
|
464 |
_FILEARGS=''; |
_FILEARGS=''; |
470 |
# _TMP_* temporary files |
# _TMP_* temporary files |
471 |
_TMP_DIR=''; |
_TMP_DIR=''; |
472 |
_TMP_CAT=''; |
_TMP_CAT=''; |
473 |
|
_TMP_CONF=''; |
474 |
_TMP_STDIN=''; |
_TMP_STDIN=''; |
475 |
|
|
476 |
|
|
481 |
# |
# |
482 |
reset() |
reset() |
483 |
{ |
{ |
484 |
if test "$#" -ne 0; |
if test "$#" -ne 0 |
485 |
then |
then |
486 |
error "reset() does not have arguments."; |
error "reset() does not have arguments."; |
487 |
fi; |
fi; |
566 |
|
|
567 |
|
|
568 |
############## |
############## |
569 |
|
# echo1 (<text>*) |
570 |
|
# |
571 |
|
# Output to stdout. |
572 |
|
# |
573 |
|
# Arguments : arbitrary text including `-'. |
574 |
|
# |
575 |
|
echo1() |
576 |
|
{ |
577 |
|
cat <<EOF |
578 |
|
$* |
579 |
|
EOF |
580 |
|
} |
581 |
|
|
582 |
|
|
583 |
|
############## |
584 |
# echo2 (<text>*) |
# echo2 (<text>*) |
585 |
# |
# |
586 |
# Output to stderr. |
# Output to stderr. |
604 |
# |
# |
605 |
landmark() |
landmark() |
606 |
{ |
{ |
607 |
if test _"${_DEBUG_LM}"_ = _yes_; |
if test _"${_DEBUG_LM}"_ = _yes_ |
608 |
then |
then |
609 |
echo2 "LM: $*" >&2; |
echo2 "LM: $*"; |
610 |
fi; |
fi; |
611 |
} |
} |
612 |
|
|
620 |
# |
# |
621 |
clean_up() |
clean_up() |
622 |
{ |
{ |
623 |
if test -d "${_TMP_DIR}"; |
cd "${_START_DIR}" >"${_NULL_DEV}" 2>&1; |
624 |
|
if test _"${_TMP_DIR}"_ != __ |
625 |
then |
then |
626 |
eval rm -f -r "'${_TMP_DIR}'" >${_NULL_DEV} 2>&1; |
if test -d "${_TMP_DIR}" || test -f "${_TMP_DIR}" |
627 |
|
then |
628 |
|
rm -f -r "${_TMP_DIR}" >${_NULL_DEV} 2>&1; |
629 |
|
fi; |
630 |
fi; |
fi; |
631 |
} |
} |
632 |
|
|
698 |
# |
# |
699 |
func_check() |
func_check() |
700 |
{ |
{ |
701 |
if test "$#" -lt 3; |
if test "$#" -lt 3 |
702 |
then |
then |
703 |
error 'func_check() needs at least 3 arguments.'; |
error 'func_check() needs at least 3 arguments.'; |
704 |
fi; |
fi; |
749 |
shift; |
shift; |
750 |
shift; |
shift; |
751 |
shift; |
shift; |
752 |
if test "$#" "${fc_op}" "${fc_nargs}"; |
if test "$#" "${fc_op}" "${fc_nargs}" |
753 |
then |
then |
754 |
do_nothing; |
do_nothing; |
755 |
else |
else |
757 |
${fc_fname}"'() needs '"${fc_comp} ${fc_nargs}"' argument'"${fc_s}"'.'; |
${fc_fname}"'() needs '"${fc_comp} ${fc_nargs}"' argument'"${fc_s}"'.'; |
758 |
fi; |
fi; |
759 |
func_push "${fc_fname}"; |
func_push "${fc_fname}"; |
760 |
if test _"${_DEBUG}"_ = _yes_; |
if test _"${_DEBUG}"_ = _yes_ |
761 |
then |
then |
762 |
echo2 '+++ '"${fc_fname} $@"; |
echo2 '+++ '"${fc_fname} $@"; |
763 |
echo2 '>>> '"${_FUNC_STACK}"; |
echo2 '>>> '"${_FUNC_STACK}"; |
783 |
# |
# |
784 |
func_pop() |
func_pop() |
785 |
{ |
{ |
786 |
if test "$#" -ne 0; |
if test "$#" -ne 0 |
787 |
then |
then |
788 |
error 'func_pop() does not have arguments.'; |
error 'func_pop() does not have arguments.'; |
789 |
fi; |
fi; |
790 |
case "${_FUNC_STACK}" in |
case "${_FUNC_STACK}" in |
791 |
'') |
'') |
792 |
if test _"${_DEBUG}"_ = _yes_; |
if test _"${_DEBUG}"_ = _yes_ |
793 |
then |
then |
794 |
error 'func_pop(): stack is empty.'; |
error 'func_pop(): stack is empty.'; |
795 |
fi; |
fi; |
796 |
;; |
;; |
797 |
*!*) |
*!*) |
798 |
# split at first bang `!'. |
# split at first bang `!'. |
799 |
_FUNC_STACK="$(echo x"${_FUNC_STACK}" | sed -e ' |
_FUNC_STACK="$(echo1 "${_FUNC_STACK}" | sed -e 's/^[^!]*!//')"; |
|
s/^x// |
|
|
s/^[^!]*!// |
|
|
')"; |
|
800 |
;; |
;; |
801 |
*) |
*) |
802 |
_FUNC_STACK=''; |
_FUNC_STACK=''; |
803 |
;; |
;; |
804 |
esac; |
esac; |
805 |
if test _"${_DEBUG}"_ = _yes_; |
if test _"${_DEBUG}"_ = _yes_ |
806 |
then |
then |
807 |
echo2 '<<< '"${_FUNC_STACK}"; |
echo2 '<<< '"${_FUNC_STACK}"; |
808 |
fi; |
fi; |
823 |
# |
# |
824 |
func_push() |
func_push() |
825 |
{ |
{ |
826 |
if test "$#" -ne 1; |
if test "$#" -ne 1 |
827 |
then |
then |
828 |
error 'func_push() needs 1 argument.'; |
error 'func_push() needs 1 argument.'; |
829 |
fi; |
fi; |
830 |
case "$1" in |
case "$1" in |
831 |
*'!'*) |
*'!'*) |
832 |
# remove all bangs `!'. |
# remove all bangs `!'. |
833 |
fp_element="$(echo x"$1" | sed -e ' |
fp_element="$(echo1 "$1" | sed -e 's/!//g')"; |
|
s/^x// |
|
|
s/!//g |
|
|
')"; |
|
834 |
;; |
;; |
835 |
*) |
*) |
836 |
fp_element="$1"; |
fp_element="$1"; |
837 |
;; |
;; |
838 |
esac; |
esac; |
839 |
if test _"${_FUNC_STACK}"_ = __; |
if test _"${_FUNC_STACK}"_ = __ |
840 |
then |
then |
841 |
_FUNC_STACK="${fp_element}"; |
_FUNC_STACK="${fp_element}"; |
842 |
else |
else |
872 |
|
|
873 |
if test _"$(echo xTesTx \ |
if test _"$(echo xTesTx \ |
874 |
| sed -e 's/^.\([Tt]e*x*sTT*\).*$/\1/' \ |
| sed -e 's/^.\([Tt]e*x*sTT*\).*$/\1/' \ |
875 |
| sed -e 's|T|t|g')"_ != _test_; |
| sed -e 's|T|t|g')"_ != _test_ |
876 |
then |
then |
877 |
error 'Test of "sed" command failed.'; |
error 'Test of "sed" command failed.'; |
878 |
fi; |
fi; |
881 |
######################################################################## |
######################################################################## |
882 |
# Test of function `cat'. |
# Test of function `cat'. |
883 |
# |
# |
884 |
if test _"$(echo test | cat)"_ != _test_; |
if test _"$(echo test | cat)"_ != _test_ |
885 |
then |
then |
886 |
error 'Test of "cat" command failed.'; |
error 'Test of "cat" command failed.'; |
887 |
fi; |
fi; |
890 |
######################################################################## |
######################################################################## |
891 |
# Test for compression. |
# Test for compression. |
892 |
# |
# |
893 |
if test _"$(echo 'test' | gzip -c -d -f - 2>${_NULL_DEV})"_ = _test_; |
if test _"$(echo 'test' | gzip -c -d -f - 2>${_NULL_DEV})"_ = _test_ |
894 |
then |
then |
895 |
_HAS_COMPRESSION='yes'; |
_HAS_COMPRESSION='yes'; |
896 |
if echo 'test' | bzip2 -c 2>${_NULL_DEV} | bzip2 -t 2>${_NULL_DEV} \ |
if echo 'test' | bzip2 -c 2>${_NULL_DEV} | bzip2 -t 2>${_NULL_DEV} \ |
897 |
&& test _"$(echo 'test' | bzip2 -c 2>${_NULL_DEV} \ |
&& test _"$(echo 'test' | bzip2 -c 2>${_NULL_DEV} \ |
898 |
| bzip2 -d -c 2>${_NULL_DEV})"_ \ |
| bzip2 -d -c 2>${_NULL_DEV})"_ \ |
899 |
= _test_; |
= _test_ |
900 |
then |
then |
901 |
_HAS_BZIP='yes'; |
_HAS_BZIP='yes'; |
902 |
else |
else |
928 |
# |
# |
929 |
apropos_run() { |
apropos_run() { |
930 |
func_check apropos_run = 1 "$@"; |
func_check apropos_run = 1 "$@"; |
931 |
if apropos apropos >${_NULL_DEV} 2>${_NULL_DEV}; |
if apropos apropos >${_NULL_DEV} 2>${_NULL_DEV} |
932 |
then |
then |
933 |
apropos "$1"; |
apropos "$1"; |
934 |
elif man --apropos man >${_NULL_DEV} 2>${_NULL_DEV}; |
elif man --apropos man >${_NULL_DEV} 2>${_NULL_DEV} |
935 |
then |
then |
936 |
man --apropos "$1"; |
man --apropos "$1"; |
937 |
elif man -k man >${_NULL_DEV} 2>${_NULL_DEV}; |
elif man -k man >${_NULL_DEV} 2>${_NULL_DEV} |
938 |
then |
then |
939 |
man -k "$1"; |
man -k "$1"; |
940 |
fi; |
fi; |
961 |
case "${bn_name}" in |
case "${bn_name}" in |
962 |
*/) |
*/) |
963 |
# delete all final slashes |
# delete all final slashes |
964 |
bn_name="$(echo x"${bn_name}" | sed -e ' |
bn_name="$(echo1 "${bn_name}" | sed -e 's|//*$||')"; |
|
s/^x// |
|
|
s|//*$|| |
|
|
')"; |
|
965 |
;; |
;; |
966 |
esac; |
esac; |
967 |
case "${bn_name}" in |
case "${bn_name}" in |
971 |
;; |
;; |
972 |
*/*) |
*/*) |
973 |
# delete everything before and including the last slash `/'. |
# delete everything before and including the last slash `/'. |
974 |
echo x"${bn_name}" | sed -e ' |
echo1 "${bn_name}" | sed -e 's|^.*//*\([^/]*\)$|\1|'; |
|
s/^x// |
|
|
s|^.*//*\([^/]*\)$|\1| |
|
|
'; |
|
975 |
;; |
;; |
976 |
*) |
*) |
977 |
cat <<EOF |
obj bn_name echo1; |
|
${bn_name} |
|
|
EOF |
|
978 |
;; |
;; |
979 |
esac; |
esac; |
980 |
eval ${_UNSET} bn_name; |
eval ${_UNSET} bn_name; |
992 |
# Arguments: 1, a file name. |
# Arguments: 1, a file name. |
993 |
# Output: the content of <file>, possibly decompressed. |
# Output: the content of <file>, possibly decompressed. |
994 |
# |
# |
995 |
if test _"${_HAS_COMPRESSION}"_ = _yes_; |
if test _"${_HAS_COMPRESSION}"_ = _yes_ |
996 |
then |
then |
997 |
cat_z() |
cat_z() |
998 |
{ |
{ |
1005 |
error 'cat_z(): for standard input use save_stdin()'; |
error 'cat_z(): for standard input use save_stdin()'; |
1006 |
;; |
;; |
1007 |
esac; |
esac; |
1008 |
if obj _HAS_BZIP is_yes; |
if obj _HAS_BZIP is_yes |
1009 |
then |
then |
1010 |
if bzip2 -t "$1" 2>${_NULL_DEV}; |
if bzip2 -t "$1" 2>${_NULL_DEV} |
1011 |
then |
then |
1012 |
bzip2 -c -d "$1" 2>${_NULL_DEV}; |
bzip2 -c -d "$1" 2>${_NULL_DEV}; |
1013 |
eval "${return_ok}"; |
eval "${return_ok}"; |
1057 |
dirname_append() |
dirname_append() |
1058 |
{ |
{ |
1059 |
func_check dirname_append = 2 "$@"; |
func_check dirname_append = 2 "$@"; |
1060 |
if is_empty "$1"; |
if is_empty "$1" |
1061 |
then |
then |
1062 |
error "dir_append(): first argument is empty."; |
error "dir_append(): first argument is empty."; |
1063 |
fi; |
fi; |
1064 |
if is_empty "$2"; |
if is_empty "$2" |
1065 |
then |
then |
1066 |
cat <<EOF |
echo1 "$1"; |
|
$1 |
|
|
EOF |
|
1067 |
else |
else |
1068 |
dirname_chop "$1"/"$2"; |
dirname_chop "$1"/"$2"; |
1069 |
fi; |
fi; |
1085 |
{ |
{ |
1086 |
func_check dirname_chop = 1 "$@"; |
func_check dirname_chop = 1 "$@"; |
1087 |
# replace all multiple slashes by a single slash `/'. |
# replace all multiple slashes by a single slash `/'. |
1088 |
dc_res="$(echo x"$1" | sed -e ' |
dc_res="$(echo1 "$1" | sed -e 's|///*|/|g')"; |
|
s/^x// |
|
|
s|///*|/|g |
|
|
')"; |
|
1089 |
case "${dc_res}" in |
case "${dc_res}" in |
1090 |
?*/) |
?*/) |
1091 |
# remove trailing slash '/'; |
# remove trailing slash '/'; |
1092 |
echo x"${dc_res}" | sed -e ' |
echo1 "${dc_res}" | sed -e 's|/$||'; |
1093 |
s/^x// |
;; |
1094 |
s|/$|| |
*) |
1095 |
'; |
obj dc_res echo1 |
1096 |
;; |
;; |
|
*) cat <<EOF |
|
|
${dc_res} |
|
|
EOF |
|
|
;; |
|
1097 |
esac; |
esac; |
1098 |
eval ${_UNSET} dc_res; |
eval ${_UNSET} dc_res; |
1099 |
eval "${return_ok}"; |
eval "${return_ok}"; |
1142 |
set 'File'; |
set 'File'; |
1143 |
;; |
;; |
1144 |
*) |
*) |
1145 |
if obj _MAN_ENABLE is_yes; |
if obj _MAN_ENABLE is_yes |
1146 |
then |
then |
1147 |
if obj _MAN_FORCE is_yes; |
if obj _MAN_FORCE is_yes |
1148 |
then |
then |
1149 |
set 'Manpage' 'File'; |
set 'Manpage' 'File'; |
1150 |
else |
else |
1159 |
do |
do |
1160 |
case "$i" in |
case "$i" in |
1161 |
File) |
File) |
1162 |
if test -f "${df_filespec}"; |
if test -f "${df_filespec}" |
1163 |
then |
then |
1164 |
if test -r "${df_filespec}"; |
if test -r "${df_filespec}" |
1165 |
then |
then |
1166 |
register_file "${df_filespec}"; |
register_file "${df_filespec}"; |
1167 |
eval ${_UNSET} df_filespec; |
eval ${_UNSET} df_filespec; |
1168 |
|
eval ${_UNSET} df_no_man; |
1169 |
eval "${return_good}"; |
eval "${return_good}"; |
1170 |
else |
else |
1171 |
echo2 "could not read \`${df_filespec}'"; |
echo2 "could not read \`${df_filespec}'"; |
1172 |
eval ${_UNSET} df_filespec; |
eval ${_UNSET} df_filespec; |
1173 |
|
eval ${_UNSET} df_no_man; |
1174 |
eval "${return_bad}"; |
eval "${return_bad}"; |
1175 |
fi; |
fi; |
1176 |
else |
else |
1177 |
|
if obj df_no_man is_not_empty |
1178 |
|
then |
1179 |
|
echo2 "\`${df_filespec}' is neither a file nor a man page." |
1180 |
|
fi; |
1181 |
|
df_no_file=yes; |
1182 |
continue; |
continue; |
1183 |
fi; |
fi; |
1184 |
;; |
;; |
1185 |
Manpage) # parse filespec as man page |
Manpage) # parse filespec as man page |
1186 |
if obj _MAN_IS_SETUP is_not_yes; |
if obj _MAN_IS_SETUP is_not_yes |
1187 |
then |
then |
1188 |
man_setup; |
man_setup; |
1189 |
fi; |
fi; |
1190 |
if man_do_filespec "${df_filespec}"; |
if man_do_filespec "${df_filespec}" |
1191 |
then |
then |
1192 |
eval ${_UNSET} df_filespec; |
eval ${_UNSET} df_filespec; |
1193 |
|
eval ${_UNSET} df_no_file; |
1194 |
eval "${return_good}"; |
eval "${return_good}"; |
1195 |
else |
else |
1196 |
|
if obj df_no_file is_not_empty |
1197 |
|
then |
1198 |
|
echo2 "\`${df_filespec}' is neither a file nor a man page." |
1199 |
|
fi; |
1200 |
|
df_no_man=yes; |
1201 |
continue; |
continue; |
1202 |
fi; |
fi; |
1203 |
;; |
;; |
1204 |
esac; |
esac; |
1205 |
done; |
done; |
1206 |
eval ${_UNSET} df_filespec; |
eval ${_UNSET} df_filespec; |
1207 |
|
eval ${_UNSET} df_no_file; |
1208 |
|
eval ${_UNSET} df_no_man; |
1209 |
eval "${return_bad}"; |
eval "${return_bad}"; |
1210 |
} # do_filearg() |
} # do_filearg() |
1211 |
|
|
1287 |
get_first_essential() |
get_first_essential() |
1288 |
{ |
{ |
1289 |
func_check get_first_essential '>=' 0 "$@"; |
func_check get_first_essential '>=' 0 "$@"; |
1290 |
if is_equal "$#" 0; |
if is_equal "$#" 0 |
1291 |
then |
then |
1292 |
eval "${return_ok}"; |
eval "${return_ok}"; |
1293 |
fi; |
fi; |
1294 |
for i |
for i |
1295 |
do |
do |
1296 |
gfe_var="$i"; |
gfe_var="$i"; |
1297 |
if obj gfe_var is_not_empty; |
if obj gfe_var is_not_empty |
1298 |
then |
then |
1299 |
cat <<EOF |
obj gfe_var echo1; |
|
${gfe_var} |
|
|
EOF |
|
1300 |
eval ${_UNSET} gfe_var; |
eval ${_UNSET} gfe_var; |
1301 |
eval "${return_ok}"; |
eval "${return_ok}"; |
1302 |
fi; |
fi; |
1321 |
is_dir() |
is_dir() |
1322 |
{ |
{ |
1323 |
func_check is_dir = 1 "$@"; |
func_check is_dir = 1 "$@"; |
1324 |
if test -d "$1" && test -r "$1"; |
if test _"$1"_ != __ && test -d "$1" && test -r "$1" |
1325 |
then |
then |
1326 |
eval "${return_yes}"; |
eval "${return_yes}"; |
1327 |
fi; |
fi; |
1340 |
is_empty() |
is_empty() |
1341 |
{ |
{ |
1342 |
func_check is_empty = 1 "$@"; |
func_check is_empty = 1 "$@"; |
1343 |
if test _"$1"_ = __; |
if test _"$1"_ = __ |
1344 |
then |
then |
1345 |
eval "${return_yes}"; |
eval "${return_yes}"; |
1346 |
fi; |
fi; |
1359 |
is_equal() |
is_equal() |
1360 |
{ |
{ |
1361 |
func_check is_equal = 2 "$@"; |
func_check is_equal = 2 "$@"; |
1362 |
if test _"$1"_ = _"$2"_; |
if test _"$1"_ = _"$2"_ |
1363 |
then |
then |
1364 |
eval "${return_yes}"; |
eval "${return_yes}"; |
1365 |
fi; |
fi; |
1379 |
is_existing() |
is_existing() |
1380 |
{ |
{ |
1381 |
func_check is_existing = 1 "$@"; |
func_check is_existing = 1 "$@"; |
1382 |
if test -f "$1" || test -d "$1"; |
if test _"$1"_ = __ |
1383 |
|
then |
1384 |
|
eval "${return_no}"; |
1385 |
|
fi; |
1386 |
|
if test -f "$1" || test -d "$1" || test -c "$1" |
1387 |
then |
then |
1388 |
eval "${return_yes}"; |
eval "${return_yes}"; |
1389 |
fi; |
fi; |
1402 |
is_file() |
is_file() |
1403 |
{ |
{ |
1404 |
func_check is_file = 1 "$@"; |
func_check is_file = 1 "$@"; |
1405 |
if test -f "$1" && test -r "$1"; |
if test _"$1"_ != __ && test -f "$1" && test -r "$1" |
1406 |
then |
then |
1407 |
eval "${return_yes}"; |
eval "${return_yes}"; |
1408 |
fi; |
fi; |
1423 |
is_non_empty_file() |
is_non_empty_file() |
1424 |
{ |
{ |
1425 |
func_check is_non_empty_file = 1 "$@"; |
func_check is_non_empty_file = 1 "$@"; |
1426 |
if is_file "$1" && test -s "$1"; |
if is_file "$1" && test -s "$1" |
1427 |
then |
then |
1428 |
eval "${return_yes}"; |
eval "${return_yes}"; |
1429 |
fi; |
fi; |
1442 |
is_not_dir() |
is_not_dir() |
1443 |
{ |
{ |
1444 |
func_check is_not_dir = 1 "$@"; |
func_check is_not_dir = 1 "$@"; |
1445 |
if is_dir "$1"; |
if is_dir "$1" |
1446 |
then |
then |
1447 |
eval "${return_no}"; |
eval "${return_no}"; |
1448 |
fi; |
fi; |
1461 |
is_not_empty() |
is_not_empty() |
1462 |
{ |
{ |
1463 |
func_check is_not_empty = 1 "$@"; |
func_check is_not_empty = 1 "$@"; |
1464 |
if is_empty "$1"; |
if is_empty "$1" |
1465 |
then |
then |
1466 |
eval "${return_no}"; |
eval "${return_no}"; |
1467 |
fi; |
fi; |
1479 |
is_not_equal() |
is_not_equal() |
1480 |
{ |
{ |
1481 |
func_check is_not_equal = 2 "$@"; |
func_check is_not_equal = 2 "$@"; |
1482 |
if is_equal "$1" "$2"; |
if is_equal "$1" "$2" |
1483 |
then |
then |
1484 |
eval "${return_no}"; |
eval "${return_no}"; |
1485 |
fi |
fi |
1497 |
is_not_file() |
is_not_file() |
1498 |
{ |
{ |
1499 |
func_check is_not_file '>=' 1 "$@"; |
func_check is_not_file '>=' 1 "$@"; |
1500 |
if is_file "$1"; |
if is_file "$1" |
1501 |
then |
then |
1502 |
eval "${return_no}"; |
eval "${return_no}"; |
1503 |
fi; |
fi; |
1516 |
is_not_prog() |
is_not_prog() |
1517 |
{ |
{ |
1518 |
func_check is_not_prog '>=' 1 "$@"; |
func_check is_not_prog '>=' 1 "$@"; |
1519 |
if where_is "$1" >${_NULL_DEV}; |
if where_is "$1" >${_NULL_DEV} |
1520 |
then |
then |
1521 |
eval "${return_no}"; |
eval "${return_no}"; |
1522 |
fi; |
fi; |
1534 |
is_not_writable() |
is_not_writable() |
1535 |
{ |
{ |
1536 |
func_check is_not_writable '>=' 1 "$@"; |
func_check is_not_writable '>=' 1 "$@"; |
1537 |
if is_writable "$1"; |
if is_writable "$1" |
1538 |
then |
then |
1539 |
eval "${return_no}"; |
eval "${return_no}"; |
1540 |
fi; |
fi; |
1552 |
is_not_yes() |
is_not_yes() |
1553 |
{ |
{ |
1554 |
func_check is_not_yes = 1 "$@"; |
func_check is_not_yes = 1 "$@"; |
1555 |
if is_yes "$1"; |
if is_yes "$1" |
1556 |
then |
then |
1557 |
eval "${return_no}"; |
eval "${return_no}"; |
1558 |
fi; |
fi; |
1576 |
eval "${return_no}"; |
eval "${return_no}"; |
1577 |
;; |
;; |
1578 |
*) |
*) |
1579 |
if where_is "$1" >${_NULL_DEV}; |
if where_is "$1" >${_NULL_DEV} |
1580 |
then |
then |
1581 |
eval "${return_yes}"; |
eval "${return_yes}"; |
1582 |
fi; |
fi; |
1596 |
is_writable() |
is_writable() |
1597 |
{ |
{ |
1598 |
func_check is_writable '>=' 1 "$@"; |
func_check is_writable '>=' 1 "$@"; |
1599 |
if test -r "$1"; |
if test _"$1"_ = __ |
1600 |
then |
then |
1601 |
if test -w "$1"; |
eval "${return_no}"; |
1602 |
|
fi; |
1603 |
|
if test -r "$1" |
1604 |
|
then |
1605 |
|
if test -w "$1" |
1606 |
then |
then |
1607 |
eval "${return_yes}"; |
eval "${return_yes}"; |
1608 |
fi; |
fi; |
1622 |
is_yes() |
is_yes() |
1623 |
{ |
{ |
1624 |
func_check is_yes = 1 "$@"; |
func_check is_yes = 1 "$@"; |
1625 |
if is_equal "$1" 'yes'; |
if is_equal "$1" 'yes' |
1626 |
then |
then |
1627 |
eval "${return_yes}"; |
eval "${return_yes}"; |
1628 |
fi; |
fi; |
1641 |
|
|
1642 |
|
|
1643 |
######################################################################## |
######################################################################## |
1644 |
# leave () |
# leave ([<code>]) |
1645 |
# |
# |
1646 |
# Clean exit without an error. |
# Clean exit without an error or with <code>. |
1647 |
# |
# |
1648 |
leave() |
leave() |
1649 |
{ |
{ |
1650 |
clean_up; |
clean_up; |
1651 |
exit "${_OK}"; |
if test $# = 0 |
1652 |
|
then |
1653 |
|
exit "${_OK}"; |
1654 |
|
else |
1655 |
|
exit "$1"; |
1656 |
|
fi; |
1657 |
} |
} |
1658 |
|
|
1659 |
|
|
1665 |
# data consists of space-separated single-quoted elements. So a list |
# data consists of space-separated single-quoted elements. So a list |
1666 |
# has the form "'first' 'second' '...' 'last'". See list_append() for |
# has the form "'first' 'second' '...' 'last'". See list_append() for |
1667 |
# more details on the list structure. The array elements of `list' |
# more details on the list structure. The array elements of `list' |
1668 |
# can be get by `set x $list; shift`. |
# can be get by `eval set x "$list"; shift`. |
1669 |
|
|
1670 |
|
|
1671 |
######################################################################## |
######################################################################## |
1694 |
# escape each single quote by replacing each |
# escape each single quote by replacing each |
1695 |
# "'" (squote) by "'\''" (squote bslash squote squote); |
# "'" (squote) by "'\''" (squote bslash squote squote); |
1696 |
# note that the backslash must be doubled in the following `sed' |
# note that the backslash must be doubled in the following `sed' |
1697 |
la_element="$(echo x"${la_s}" | sed -e ' |
la_element="$(echo1 "${la_s}" | sed -e 's/'"${_SQ}"'/&\\&&/g')"; |
|
s/^x// |
|
|
s/'"${_SQUOTE}"'/&\\&&/g |
|
|
')"; |
|
1698 |
;; |
;; |
1699 |
'') |
'') |
1700 |
la_element=""; |
la_element=""; |
1703 |
la_element="${la_s}"; |
la_element="${la_s}"; |
1704 |
;; |
;; |
1705 |
esac; |
esac; |
1706 |
if obj la_list is_empty; |
if obj la_list is_empty |
1707 |
then |
then |
1708 |
la_list="'${la_element}'"; |
la_list="'${la_element}'"; |
1709 |
else |
else |
1766 |
lfc_short_a="$(obj_data "$1"_SHORT_ARG)"; # short options, with argument |
lfc_short_a="$(obj_data "$1"_SHORT_ARG)"; # short options, with argument |
1767 |
lfc_long_n="$(obj_data "$1"_LONG_NA)"; # long options, no argument |
lfc_long_n="$(obj_data "$1"_LONG_NA)"; # long options, no argument |
1768 |
lfc_long_a="$(obj_data "$1"_LONG_ARG)"; # long options, with argument |
lfc_long_a="$(obj_data "$1"_LONG_ARG)"; # long options, with argument |
1769 |
if obj lfc_short_n is_empty; |
if obj lfc_short_n is_empty |
1770 |
then |
then |
1771 |
error 'list_from_cmdline(): no $'"$1"'_SHORT_NA options.'; |
error 'list_from_cmdline(): no $'"$1"'_SHORT_NA options.'; |
1772 |
fi; |
fi; |
1773 |
if obj lfc_short_a is_empty; |
if obj lfc_short_a is_empty |
1774 |
then |
then |
1775 |
error 'list_from_cmdline(): no $'"$1"'_SHORT_ARG options.'; |
error 'list_from_cmdline(): no $'"$1"'_SHORT_ARG options.'; |
1776 |
fi; |
fi; |
1777 |
if obj lfc_long_n is_empty; |
if obj lfc_long_n is_empty |
1778 |
then |
then |
1779 |
error 'list_from_cmdline(): no $'"$1"'_LONG_NA options.'; |
error 'list_from_cmdline(): no $'"$1"'_LONG_NA options.'; |
1780 |
fi; |
fi; |
1781 |
if obj lfc_long_a is_empty; |
if obj lfc_long_a is_empty |
1782 |
then |
then |
1783 |
error 'list_from_cmdline(): no $'"$1"'_LONG_ARG options.'; |
error 'list_from_cmdline(): no $'"$1"'_LONG_ARG options.'; |
1784 |
fi; |
fi; |
1785 |
shift; |
shift; |
1786 |
lfc_fn='list_from_cmdline():'; # for error messages |
if is_equal "$#" 0 |
|
if is_equal "$#" 0; |
|
1787 |
then |
then |
1788 |
cat <<EOF |
echo1 -- |
|
-- |
|
|
EOF |
|
1789 |
eval ${_UNSET} lfc_fparams; |
eval ${_UNSET} lfc_fparams; |
|
eval ${_UNSET} lfc_fn; |
|
1790 |
eval ${_UNSET} lfc_short_a; |
eval ${_UNSET} lfc_short_a; |
1791 |
eval ${_UNSET} lfc_short_n; |
eval ${_UNSET} lfc_short_n; |
1792 |
eval ${_UNSET} lfc_long_a; |
eval ${_UNSET} lfc_long_a; |
1796 |
fi; |
fi; |
1797 |
lfc_fparams=''; |
lfc_fparams=''; |
1798 |
lfc_result=''; |
lfc_result=''; |
1799 |
while test "$#" -ge 1; |
while test "$#" -ge 1 |
1800 |
do |
do |
1801 |
lfc_arg="$1"; |
lfc_arg="$1"; |
1802 |
shift; |
shift; |
1803 |
case "${lfc_arg}" in |
case "${lfc_arg}" in |
1804 |
--) break; ;; |
--) break; ;; |
1805 |
--?*) |
--?*) |
1806 |
# delete leading '--'; |
# delete leading '--'; |
1807 |
lfc_opt="$(echo x"${lfc_arg}" | sed -e 's/^x--//')"; |
lfc_abbrev="$(echo1 "${lfc_arg}" | sed -e 's/^--//')"; |
1808 |
if list_has lfc_long_n "${lfc_opt}"; |
lfc_opt="$(list_single_from_abbrev lfc_long_n "${lfc_abbrev}")"; |
1809 |
|
if obj lfc_opt is_not_empty |
1810 |
|
then |
1811 |
|
# long option, no argument |
1812 |
|
list_append lfc_result "--${lfc_opt}"; |
1813 |
|
continue; |
1814 |
|
fi; |
1815 |
|
# test on `--opt=arg' |
1816 |
|
if string_contains "${lfc_abbrev}" '=' |
1817 |
|
then |
1818 |
|
lfc_with_equal="${lfc_abbrev}"; |
1819 |
|
# extract option by deleting from the first '=' to the end |
1820 |
|
lfc_abbrev="$(echo1 "${lfc_with_equal}" | \ |
1821 |
|
sed -e 's/^\([^=]*\)=.*$/\1/')"; |
1822 |
|
lfc_opt="$(list_single_from_abbrev lfc_long_a "${lfc_abbrev}")"; |
1823 |
|
if obj lfc_opt is_not_empty |
1824 |
then |
then |
1825 |
# long option, no argument |
# get the option argument by deleting up to first `=' |
1826 |
list_append lfc_result "--${lfc_opt}"; |
lfc_optarg="$(echo1 "${lfc_with_equal}" | sed -e 's/^[^=]*=//')"; |
1827 |
|
list_append lfc_result "--${lfc_opt}" "${lfc_optarg}"; |
1828 |
continue; |
continue; |
1829 |
fi; |
fi; |
1830 |
# test on `--opt=arg' |
fi; |
1831 |
if string_contains "${lfc_opt}" '='; |
lfc_opt="$(list_single_from_abbrev lfc_long_a "${lfc_abbrev}")"; |
1832 |
|
if obj lfc_opt is_not_empty |
1833 |
|
then |
1834 |
|
# long option with argument |
1835 |
|
if test "$#" -le 0 |
1836 |
then |
then |
1837 |
# extract option by deleting from the first '=' to the end |
error "list_from_cmdline(): no argument for option --${lfc_opt}." |
|
lfc_lopt="$(echo x"${lfc_opt}" | sed -e ' |
|
|
s/^x// |
|
|
s/=.*$// |
|
|
')"; |
|
|
if list_has lfc_long_a "${lfc_lopt}"; |
|
|
then |
|
|
# get the option argument by deleting up to first `=' |
|
|
lfc_optarg="$(echo x"${lfc_opt}" | sed -e ' |
|
|
s/^x// |
|
|
s/^[^=]*=// |
|
|
')"; |
|
|
list_append lfc_result "--${lfc_lopt}" "${lfc_optarg}"; |
|
|
continue; |
|
|
fi; |
|
1838 |
fi; |
fi; |
1839 |
if list_has lfc_long_a "${lfc_opt}"; |
list_append lfc_result "--${lfc_opt}" "$1"; |
1840 |
|
shift; |
1841 |
|
continue; |
1842 |
|
fi; |
1843 |
|
error "list_from_cmdline(): --${lfc_opt} is not an option." |
1844 |
|
;; |
1845 |
|
-?*) # short option (cluster) |
1846 |
|
# delete leading `-'; |
1847 |
|
lfc_rest="$(echo1 "${lfc_arg}" | sed -e 's/^-//')"; |
1848 |
|
while obj lfc_rest is_not_empty |
1849 |
|
do |
1850 |
|
# get next short option from cluster (first char of $lfc_rest) |
1851 |
|
lfc_optchar="$(echo1 "${lfc_rest}" | sed -e 's/^\(.\).*$/\1/')"; |
1852 |
|
# remove first character from ${lfc_rest}; |
1853 |
|
lfc_rest="$(echo1 "${lfc_rest}" | sed -e 's/^.//')"; |
1854 |
|
if list_has lfc_short_n "${lfc_optchar}" |
1855 |
then |
then |
1856 |
# long option with argument |
list_append lfc_result "-${lfc_optchar}"; |
|
if test "$#" -le 0; |
|
|
then |
|
|
error "list_from_cmdline(): \ |
|
|
${lfc_fn} no argument for option --${lfc_opt}." |
|
|
fi; |
|
|
list_append lfc_result "--${lfc_opt}" "$1"; |
|
|
shift; |
|
1857 |
continue; |
continue; |
1858 |
fi; |
elif list_has lfc_short_a "${lfc_optchar}" |
1859 |
error "list_from_cmdline(): ${lfc_fn} --${lfc_opt} is not an option." |
then |
1860 |
;; |
if obj lfc_rest is_empty |
|
-?*) # short option (cluster) |
|
|
# delete leading `-'; |
|
|
lfc_rest="$(echo x"${lfc_arg}" | sed -e 's/^x-//')"; |
|
|
while obj lfc_rest is_not_empty; |
|
|
do |
|
|
# get next short option from cluster (first char of $lfc_rest) |
|
|
lfc_optchar="$(echo x"${lfc_rest}" | sed -e 's/^x\(.\).*$/\1/')"; |
|
|
# remove first character from ${lfc_rest}; |
|
|
lfc_rest="$(echo x"${lfc_rest}" | sed -e 's/^x.//')"; |
|
|
if list_has lfc_short_n "${lfc_optchar}"; |
|
|
then |
|
|
list_append lfc_result "-${lfc_optchar}"; |
|
|
continue; |
|
|
elif list_has lfc_short_a "${lfc_optchar}"; |
|
1861 |
then |
then |
1862 |
if obj lfc_rest is_empty; |
if test "$#" -ge 1 |
1863 |
then |
then |
1864 |
if test "$#" -ge 1; |
list_append lfc_result "-${lfc_optchar}" "$1"; |
1865 |
then |
shift; |
|
list_append lfc_result "-${lfc_optchar}" "$1"; |
|
|
shift; |
|
|
continue; |
|
|
else |
|
|
error "list_from_cmdline(): \ |
|
|
${lfc_fn}"' no argument for option -'"${lfc_optchar}." |
|
|
fi; |
|
|
else # rest is the argument |
|
|
list_append lfc_result "-${lfc_optchar}" "${lfc_rest}"; |
|
|
lfc_rest=''; |
|
1866 |
continue; |
continue; |
1867 |
|
else |
1868 |
|
error 'list_from_cmdline(): no argument for option -'\ |
1869 |
|
"${lfc_optchar}." |
1870 |
fi; |
fi; |
1871 |
else |
else # rest is the argument |
1872 |
error "list_from_cmdline(): \ |
list_append lfc_result "-${lfc_optchar}" "${lfc_rest}"; |
1873 |
${lfc_fn} unknown option -${lfc_optchar}." |
lfc_rest=''; |
1874 |
|
continue; |
1875 |
fi; |
fi; |
1876 |
done; |
else |
1877 |
;; |
error "list_from_cmdline(): unknown option -${lfc_optchar}." |
1878 |
*) |
fi; |
1879 |
# Here, $lfc_arg is not an option, so a file parameter. |
done; |
1880 |
list_append lfc_fparams "${lfc_arg}"; |
;; |
1881 |
|
*) |
1882 |
|
# Here, $lfc_arg is not an option, so a file parameter. |
1883 |
|
list_append lfc_fparams "${lfc_arg}"; |
1884 |
|
|
1885 |
# Ignore the strange option handling of $POSIXLY_CORRECT to |
# Ignore the strange POSIX option handling to end option |
1886 |
# end option parsing after the first file name argument. To |
# parsing after the first file name argument. To reuse it, do |
1887 |
# reuse it, do a `break' here if $POSIXLY_CORRECT is |
# a `break' here if $POSIXLY_CORRECT of `bash' is not empty. |
1888 |
# non-empty. |
# When `bash' is called as `sh' $POSIXLY_CORRECT is set |
1889 |
;; |
# automatically to `y'. |
1890 |
|
;; |
1891 |
esac; |
esac; |
1892 |
done; |
done; |
1893 |
list_append lfc_result '--'; |
list_append lfc_result '--'; |
1894 |
if obj lfc_fparams is_not_empty; |
if obj lfc_fparams is_not_empty |
1895 |
then |
then |
1896 |
lfc_result="${lfc_result} ${lfc_fparams}"; |
lfc_result="${lfc_result} ${lfc_fparams}"; |
1897 |
fi; |
fi; |
1898 |
if test "$#" -gt 0; |
if test "$#" -gt 0 |
1899 |
then |
then |
1900 |
list_append lfc_result "$@"; |
list_append lfc_result "$@"; |
1901 |
fi; |
fi; |
1902 |
cat <<EOF |
obj lfc_result echo1; |
1903 |
${lfc_result} |
eval ${_UNSET} lfc_abbrev; |
|
EOF |
|
1904 |
eval ${_UNSET} lfc_fparams; |
eval ${_UNSET} lfc_fparams; |
|
eval ${_UNSET} lfc_fn; |
|
1905 |
eval ${_UNSET} lfc_short_a; |
eval ${_UNSET} lfc_short_a; |
1906 |
eval ${_UNSET} lfc_short_n; |
eval ${_UNSET} lfc_short_n; |
1907 |
eval ${_UNSET} lfc_long_a; |
eval ${_UNSET} lfc_long_a; |
1911 |
eval ${_UNSET} lfc_opt; |
eval ${_UNSET} lfc_opt; |
1912 |
eval ${_UNSET} lfc_opt_arg; |
eval ${_UNSET} lfc_opt_arg; |
1913 |
eval ${_UNSET} lfc_opt_char; |
eval ${_UNSET} lfc_opt_char; |
1914 |
eval ${_UNSET} lfc_lopt; |
eval ${_UNSET} lfc_with_equal; |
1915 |
eval ${_UNSET} lfc_rest; |
eval ${_UNSET} lfc_rest; |
1916 |
eval "${return_ok}"; |
eval "${return_ok}"; |
1917 |
} # list_from_cmdline() |
} # list_from_cmdline() |
1934 |
func_check list_from_split = 2 "$@"; |
func_check list_from_split = 2 "$@"; |
1935 |
|
|
1936 |
# precede each space or tab by a backslash `\' (doubled for `sed') |
# precede each space or tab by a backslash `\' (doubled for `sed') |
1937 |
lfs_s="$(echo x"$1" | sed -e ' |
lfs_s="$(echo1 "$1" | sed -e 's/\(['"${_SP}${_TAB}"']\)/\\\1/g')"; |
|
s/^x// |
|
|
s/\(['"${_SPACE}${_TAB}"']\)/\\\1/g |
|
|
')"; |
|
1938 |
|
|
1939 |
# replace split character of string by the list separator ` ' (space). |
# replace split character of string by the list separator ` ' (space). |
1940 |
case "$2" in |
case "$2" in |
1941 |
/) # cannot use normal `sed' separator |
/) # cannot use normal `sed' separator |
1942 |
echo x"${lfs_s}" | sed -e ' |
echo1 "${lfs_s}" | sed -e 's|'"$2"'| |g'; |
|
s/^x// |
|
|
s|'"$2"'| |g |
|
|
'; |
|
1943 |
;; |
;; |
1944 |
?) # use normal `sed' separator |
?) # use normal `sed' separator |
1945 |
echo x"${lfs_s}" | sed -e ' |
echo1 "${lfs_s}" | sed -e 's/'"$2"'/ /g'; |
|
s/^x// |
|
|
s/'"$2"'/ /g |
|
|
'; |
|
1946 |
;; |
;; |
1947 |
??*) |
??*) |
1948 |
error 'list_from_split(): separator must be a single character.'; |
error 'list_from_split(): separator must be a single character.'; |
1978 |
func_check list_get = 1 "$@"; |
func_check list_get = 1 "$@"; |
1979 |
eval lg_list='"${'$1'}"'; |
eval lg_list='"${'$1'}"'; |
1980 |
# remove leading and final space characters |
# remove leading and final space characters |
1981 |
lg_list="$(echo x"${lg_list}" | sed -e ' |
lg_list="$(echo1 "${lg_list}" | sed -e ' |
1982 |
s/^x['"${_SPACE}${_TAB}"']*// |
s/^['"${_SP}${_TAB}"']*// |
1983 |
s/['"${_SPACE}${_TAB}"']*$// |
s/['"${_SP}${_TAB}"']*$// |
1984 |
')"; |
')"; |
1985 |
case "${lg_list}" in |
case "${lg_list}" in |
1986 |
'') |
'') |
1988 |
eval "${return_ok}"; |
eval "${return_ok}"; |
1989 |
;; |
;; |
1990 |
\'*\') |
\'*\') |
1991 |
cat <<EOF |
obj lg_list echo1; |
|
${lg_list} |
|
|
EOF |
|
1992 |
eval ${_UNSET} lg_list; |
eval ${_UNSET} lg_list; |
1993 |
eval "${return_ok}"; |
eval "${return_ok}"; |
1994 |
;; |
;; |
2004 |
######################################################################## |
######################################################################## |
2005 |
# list_has (<var_name> <element>) |
# list_has (<var_name> <element>) |
2006 |
# |
# |
2007 |
|
# Test whether the list <var_name> has the element <element>. |
2008 |
|
# |
2009 |
# Arguments: 2 |
# Arguments: 2 |
2010 |
# <var_name>: a variable name for a list of single-quoted elements |
# <var_name>: a variable name for a list of single-quoted elements |
2011 |
# <element>: some sequence of characters. |
# <element>: some sequence of characters. |
2012 |
# Output: |
# |
2013 |
# if <list> is empty: "'<element>' '...'" |
# Variable prefix: lh |
|
# otherwise: "list '<element>' ..." |
|
2014 |
# |
# |
2015 |
list_has() |
list_has() |
2016 |
{ |
{ |
2017 |
func_check list_has = 2 "$@"; |
func_check list_has = 2 "$@"; |
2018 |
eval _list='"${'$1'}"'; |
eval lh_list='"${'$1'}"'; |
2019 |
if obj _list is_empty; |
if obj lh_list is_empty |
2020 |
then |
then |
2021 |
|
eval "${_UNSET}" lh_list; |
2022 |
eval "${return_no}"; |
eval "${return_no}"; |
2023 |
fi; |
fi; |
|
_element="$2"; |
|
2024 |
case "$2" in |
case "$2" in |
2025 |
\'*\') _element="$2"; ;; |
\'*\') lh_element=" $2 "; ;; |
2026 |
*) _element="'$2'"; ;; |
*) lh_element=" '$2' "; ;; |
2027 |
esac; |
esac; |
2028 |
if string_contains "${_list}" "${_element}"; |
if string_contains " ${lh_list} " "${lh_element}" |
2029 |
then |
then |
2030 |
|
eval "${_UNSET}" lh_list; |
2031 |
|
eval "${_UNSET}" lh_element; |
2032 |
eval "${return_yes}"; |
eval "${return_yes}"; |
2033 |
else |
else |
2034 |
|
eval "${_UNSET}" lh_list; |
2035 |
|
eval "${_UNSET}" lh_element; |
2036 |
|
eval "${return_no}"; |
2037 |
|
fi; |
2038 |
|
} |
2039 |
|
|
2040 |
|
|
2041 |
|
######################################################################## |
2042 |
|
# list_has_abbrev (<var_name> <abbrev>) |
2043 |
|
# |
2044 |
|
# Test whether the list <var_name> has an element starting with <abbrev>. |
2045 |
|
# |
2046 |
|
# Arguments: 2 |
2047 |
|
# <var_name>: a variable name for a list of single-quoted elements |
2048 |
|
# <abbrev>: some sequence of characters. |
2049 |
|
# |
2050 |
|
# Variable prefix: lha |
2051 |
|
# |
2052 |
|
list_has_abbrev() |
2053 |
|
{ |
2054 |
|
func_check list_has_abbrev = 2 "$@"; |
2055 |
|
eval lha_list='"${'$1'}"'; |
2056 |
|
if obj lha_list is_empty |
2057 |
|
then |
2058 |
|
eval "${_UNSET}" lha_list; |
2059 |
|
eval "${return_no}"; |
2060 |
|
fi; |
2061 |
|
case "$2" in |
2062 |
|
\'*) lha_element=" $(echo1 "$2" | sed -e 's/'"${_SQ}"'$//')"; ;; |
2063 |
|
*) lha_element=" '$2"; ;; |
2064 |
|
esac; |
2065 |
|
if string_contains " ${lha_list}" "${lha_element}" |
2066 |
|
then |
2067 |
|
eval "${_UNSET}" lha_list; |
2068 |
|
eval "${_UNSET}" lha_element; |
2069 |
|
eval "${return_yes}"; |
2070 |
|
else |
2071 |
|
eval "${_UNSET}" lha_list; |
2072 |
|
eval "${_UNSET}" lha_element; |
2073 |
eval "${return_no}"; |
eval "${return_no}"; |
2074 |
fi; |
fi; |
2075 |
eval "${return_ok}"; |
eval "${return_ok}"; |
2079 |
######################################################################## |
######################################################################## |
2080 |
# list_has_not (<list> <element>) |
# list_has_not (<list> <element>) |
2081 |
# |
# |
2082 |
|
# Test whether <list> has no <element>. |
2083 |
|
# |
2084 |
# Arguments: 2 |
# Arguments: 2 |
2085 |
# <list>: a space-separated list of single-quoted elements. |
# <list>: a space-separated list of single-quoted elements. |
2086 |
# <element>: some sequence of characters. |
# <element>: some sequence of characters. |
2087 |
# Output: |
# |
2088 |
# if <list> is empty: "'<element>' '...'" |
# Variable prefix: lhn |
|
# otherwise: "<list> '<element>' ..." |
|
2089 |
# |
# |
2090 |
list_has_not() |
list_has_not() |
2091 |
{ |
{ |
2092 |
func_check list_has_not = 2 "$@"; |
func_check list_has_not = 2 "$@"; |
2093 |
eval _list='"${'$1'}"'; |
eval lhn_list='"${'$1'}"'; |
2094 |
if obj _list is_empty; |
if obj lhn_list is_empty |
2095 |
then |
then |
2096 |
|
eval "${_UNSET}" lhn_list; |
2097 |
eval "${return_yes}"; |
eval "${return_yes}"; |
2098 |
fi; |
fi; |
|
_element="$2"; |
|
2099 |
case "$2" in |
case "$2" in |
2100 |
\'*\') _element="$2"; ;; |
\'*\') lhn_element=" $2 "; ;; |
2101 |
*) _element="'$2'"; ;; |
*) lhn_element="' $2 '"; ;; |
2102 |
esac; |
esac; |
2103 |
if string_contains "${_list}" "${_element}"; |
if string_contains " ${lhn_list} " "${lhn_element}" |
2104 |
then |
then |
2105 |
|
eval "${_UNSET}" lhn_list; |
2106 |
|
eval "${_UNSET}" lhn_element; |
2107 |
eval "${return_no}"; |
eval "${return_no}"; |
2108 |
else |
else |
2109 |
|
eval "${_UNSET}" lhn_list; |
2110 |
|
eval "${_UNSET}" lhn_element; |
2111 |
eval "${return_yes}"; |
eval "${return_yes}"; |
2112 |
fi; |
fi; |
2113 |
eval "${return_ok}"; |
} |
2114 |
|
|
2115 |
|
|
2116 |
|
######################################################################## |
2117 |
|
# list_single_from_abbrev (<list> <abbrev>) |
2118 |
|
# |
2119 |
|
# Check whether the list has an element starting with <abbrev>. If |
2120 |
|
# there are more than a single element an error is created. |
2121 |
|
# |
2122 |
|
# Arguments: 2 |
2123 |
|
# <list>: a variable name for a list of single-quoted elements |
2124 |
|
# <abbrev>: some sequence of characters. |
2125 |
|
# |
2126 |
|
# Output: the found element. |
2127 |
|
# |
2128 |
|
# Variable prefix: lsfa |
2129 |
|
# |
2130 |
|
list_single_from_abbrev() |
2131 |
|
{ |
2132 |
|
func_check list_single_from_abbrev = 2 "$@"; |
2133 |
|
eval lsfa_list='"${'$1'}"'; |
2134 |
|
if obj lsfa_list is_empty |
2135 |
|
then |
2136 |
|
eval "${_UNSET}" lsfa_list; |
2137 |
|
eval "${return_no}"; |
2138 |
|
fi; |
2139 |
|
lsfa_abbrev="$2"; |
2140 |
|
if list_has lsfa_list "${lsfa_abbrev}" |
2141 |
|
then |
2142 |
|
obj lsfa_abbrev echo1; |
2143 |
|
eval "${_UNSET}" lsfa_abbrev; |
2144 |
|
eval "${_UNSET}" lsfa_list; |
2145 |
|
eval "${return_yes}"; |
2146 |
|
fi; |
2147 |
|
if list_has_abbrev lsfa_list "${lsfa_abbrev}" |
2148 |
|
then |
2149 |
|
lsfa_element=''; |
2150 |
|
eval set x "${lsfa_list}"; |
2151 |
|
shift; |
2152 |
|
for i |
2153 |
|
do |
2154 |
|
case "$i" in |
2155 |
|
${lsfa_abbrev}*) |
2156 |
|
if obj lsfa_element is_not_empty |
2157 |
|
then |
2158 |
|
error "list_single_from_abbrev: the abbreviation ${lsfa_abbrev} \ |
2159 |
|
has multiple options: ${lsfa_element} and ${i}."; |
2160 |
|
fi; |
2161 |
|
lsfa_element="$i"; |
2162 |
|
;; |
2163 |
|
esac; |
2164 |
|
done; |
2165 |
|
obj lsfa_element echo1; |
2166 |
|
eval "${_UNSET}" lsfa_abbrev; |
2167 |
|
eval "${_UNSET}" lsfa_element; |
2168 |
|
eval "${_UNSET}" lsfa_list; |
2169 |
|
eval "${return_yes}"; |
2170 |
|
else |
2171 |
|
eval "${_UNSET}" lsfa_abbrev; |
2172 |
|
eval "${_UNSET}" lsfa_element; |
2173 |
|
eval "${_UNSET}" lsfa_list; |
2174 |
|
eval "${return_no}"; |
2175 |
|
fi; |
2176 |
} |
} |
2177 |
|
|
2178 |
|
|
2194 |
# Output : none. |
# Output : none. |
2195 |
# Return : `0' if man page was found, `1' else. |
# Return : `0' if man page was found, `1' else. |
2196 |
# |
# |
2197 |
# Only called from do_fileargs(), checks on $MANPATH and |
# Only called from do_fileargs(), checks on $MANPATH and $_MAN_ENABLE |
2198 |
# $_MAN_ENABLE are assumed. |
# are assumed (see man_setup()). |
2199 |
# |
# |
2200 |
# Variable prefix: mdf |
# Variable prefix: mdf |
2201 |
# |
# |
2202 |
man_do_filespec() |
man_do_filespec() |
2203 |
{ |
{ |
2204 |
func_check man_do_filespec = 1 "$@"; |
func_check man_do_filespec = 1 "$@"; |
2205 |
if obj _MAN_PATH is_empty; |
if obj _MAN_PATH is_empty |
2206 |
then |
then |
2207 |
eval "${return_bad}"; |
eval "${return_bad}"; |
2208 |
fi; |
fi; |
2209 |
if is_empty "$1"; |
if is_empty "$1" |
2210 |
then |
then |
2211 |
eval "${return_bad}"; |
eval "${return_bad}"; |
2212 |
fi; |
fi; |
2222 |
eval "${return_bad}"; |
eval "${return_bad}"; |
2223 |
;; |
;; |
2224 |
man:?*\(?*\)) # man:name(section) |
man:?*\(?*\)) # man:name(section) |
2225 |
mdf_name="$(echo x"${mdf_spec}" \ |
mdf_name="$(echo1 "${mdf_spec}" \ |
2226 |
| sed -e 's/^xman:\(..*\)(\(..*\))$/\1/')"; |
| sed -e 's/^man:\(..*\)(\(..*\))$/\1/')"; |
2227 |
mdf_section="$(echo x"${mdf_spec}" \ |
mdf_section="$(echo1 "${mdf_spec}" \ |
2228 |
| sed -e 's/^xman:\(..*\)(\(..*\))$/\2/')"; |
| sed -e 's/^man:\(..*\)(\(..*\))$/\2/')"; |
2229 |
;; |
;; |
2230 |
man:?*.[0-9on]) # man:name.section |
man:?*.[0-9on]) # man:name.section |
2231 |
mdf_name="$(echo x"${mdf_spec}" \ |
mdf_name="$(echo1 "${mdf_spec}" \ |
2232 |
| sed -e 's/^xman:\(..*\)\..$/\1/')"; |
| sed -e 's/^man:\(..*\)\..$/\1/')"; |
2233 |
mdf_section="$(echo x"${mdf_spec}" \ |
mdf_section="$(echo1 "${mdf_spec}" \ |
2234 |
| sed -e 's/^x.*\(.\)$/\1/')"; |
| sed -e 's/^.*\(.\)$/\1/')"; |
2235 |
;; |
;; |
2236 |
man:?*) # man:name |
man:?*) # man:name |
2237 |
mdf_name="$(echo x"${mdf_spec}" | sed -e 's/^xman://')"; |
mdf_name="$(echo1 "${mdf_spec}" | sed -e 's/^man://')"; |
2238 |
;; |
;; |
2239 |
?*\(?*\)) # name(section) |
?*\(?*\)) # name(section) |
2240 |
mdf_name="$(echo x"${mdf_spec}" \ |
mdf_name="$(echo1 "${mdf_spec}" \ |
2241 |
| sed -e 's/^x\(..*\)(\(..*\))$/\1/')"; |
| sed -e 's/^\(..*\)(\(..*\))$/\1/')"; |
2242 |
mdf_section="$(echo x"${mdf_spec}" \ |
mdf_section="$(echo1 "${mdf_spec}" \ |
2243 |
| sed -e 's/^x\(..*\)(\(..*\))$/\2/')"; |
| sed -e 's/^\(..*\)(\(..*\))$/\2/')"; |
2244 |
;; |
;; |
2245 |
?*.[0-9on]) # name.section |
?*.[0-9on]) # name.section |
2246 |
mdf_name="$(echo x"${mdf_spec}" \ |
mdf_name="$(echo1 "${mdf_spec}" \ |
2247 |
| sed -e 's/^x\(..*\)\..$/\1/')"; |
| sed -e 's/^\(..*\)\..$/\1/')"; |
2248 |
mdf_section="$(echo x"${mdf_spec}" \ |
mdf_section="$(echo1 "${mdf_spec}" \ |
2249 |
| sed -e 's/^x.*\(.\)$/\1/')"; |
| sed -e 's/^.*\(.\)$/\1/')"; |
2250 |
;; |
;; |
2251 |
?*) |
?*) |
2252 |
mdf_name="${mdf_spec}"; |
mdf_name="${mdf_spec}"; |
2253 |
;; |
;; |
2254 |
esac; |
esac; |
2255 |
if obj mdf_name is_empty; |
if obj mdf_name is_empty |
2256 |
then |
then |
2257 |
eval ${_UNSET} mdf_got_one; |
eval ${_UNSET} mdf_got_one; |
2258 |
eval ${_UNSET} mdf_name; |
eval ${_UNSET} mdf_name; |
2261 |
eval "${return_bad}"; |
eval "${return_bad}"; |
2262 |
fi; |
fi; |
2263 |
mdf_got_one='no'; |
mdf_got_one='no'; |
2264 |
if obj mdf_section is_empty; |
if obj mdf_section is_empty |
2265 |
then |
then |
2266 |
eval set x "${_MAN_AUTO_SEC}"; |
eval set x "${_MAN_AUTO_SEC}"; |
2267 |
shift; |
shift; |
2268 |
for s |
for s |
2269 |
do |
do |
2270 |
mdf_s="$s"; |
mdf_s="$s"; |
2271 |
if man_search_section "${mdf_name}" "${mdf_s}"; |
if man_search_section "${mdf_name}" "${mdf_s}" |
2272 |
then # found |
then # found |
2273 |
if obj _MAN_ALL is_yes; |
if obj _MAN_ALL is_yes |
2274 |
then |
then |
2275 |
mdf_got_one='yes'; |
mdf_got_one='yes'; |
2276 |
else |
else |
2284 |
fi; |
fi; |
2285 |
done; |
done; |
2286 |
else |
else |
2287 |
if man_search_section "${mdf_name}" "${mdf_section}"; |
if man_search_section "${mdf_name}" "${mdf_section}" |
2288 |
then |
then |
2289 |
eval ${_UNSET} mdf_got_one; |
eval ${_UNSET} mdf_got_one; |
2290 |
eval ${_UNSET} mdf_name; |
eval ${_UNSET} mdf_name; |
2300 |
eval "${return_bad}"; |
eval "${return_bad}"; |
2301 |
fi; |
fi; |
2302 |
fi; |
fi; |
2303 |
if obj _MAN_ALL is_yes && is_yes "${mdf_got_one}"; |
if obj _MAN_ALL is_yes && is_yes "${mdf_got_one}" |
2304 |
then |
then |
2305 |
eval ${_UNSET} mdf_got_one; |
eval ${_UNSET} mdf_got_one; |
2306 |
eval ${_UNSET} mdf_name; |
eval ${_UNSET} mdf_name; |
2335 |
error "man_register_file() expects 2 or 3 arguments."; |
error "man_register_file() expects 2 or 3 arguments."; |
2336 |
;; |
;; |
2337 |
esac; |
esac; |
2338 |
if is_empty "$1"; |
if is_empty "$1" |
2339 |
then |
then |
2340 |
error 'man_register_file(): file name is empty'; |
error 'man_register_file(): file name is empty'; |
2341 |
fi; |
fi; |
2368 |
man_search_section() |
man_search_section() |
2369 |
{ |
{ |
2370 |
func_check man_search_section = 2 "$@"; |
func_check man_search_section = 2 "$@"; |
2371 |
if obj _MAN_PATH is_empty; |
if obj _MAN_PATH is_empty |
2372 |
then |
then |
2373 |
eval "${return_bad}"; |
eval "${return_bad}"; |
2374 |
fi; |
fi; |
2375 |
if is_empty "$1"; |
if is_empty "$1" |
2376 |
then |
then |
2377 |
eval "${return_bad}"; |
eval "${return_bad}"; |
2378 |
fi; |
fi; |
2379 |
if is_empty "$2"; |
if is_empty "$2" |
2380 |
then |
then |
2381 |
eval "${return_bad}"; |
eval "${return_bad}"; |
2382 |
fi; |
fi; |
2385 |
eval set x "$(path_split "${_MAN_PATH}")"; |
eval set x "$(path_split "${_MAN_PATH}")"; |
2386 |
shift; |
shift; |
2387 |
mss_got_one='no'; |
mss_got_one='no'; |
2388 |
if obj _MAN_EXT is_empty; |
if obj _MAN_EXT is_empty |
2389 |
then |
then |
2390 |
for d |
for d |
2391 |
do |
do |
2392 |
mss_dir="$(dirname_append "$d" "man${mss_section}")"; |
mss_dir="$(dirname_append "$d" "man${mss_section}")"; |
2393 |
if obj mss_dir is_dir; |
if obj mss_dir is_dir |
2394 |
then |
then |
2395 |
mss_prefix="$(\ |
mss_prefix="$(\ |
2396 |
dirname_append "${mss_dir}" "${mss_name}.${mss_section}")"; |
dirname_append "${mss_dir}" "${mss_name}.${mss_section}")"; |
2397 |
mss_files="$(eval ls "${mss_prefix}"'*' 2>${_NULL_DEV} | |
mss_files="$(eval ls "${mss_prefix}"'*' 2>${_NULL_DEV} | |
2398 |
sed -e '\| found|s|.*||' |
sed -e '\| found|s|.*||' |
2399 |
)"; |
)"; |
2400 |
if obj mss_files is_not_empty; |
if obj mss_files is_not_empty |
2401 |
then |
then |
2402 |
# for f in $mss_files |
# for f in $mss_files |
2403 |
for f in $(eval set x ${mss_files}; shift; echo "$@") |
for f in $(eval set x ${mss_files}; shift; echo "$@") |
2404 |
do |
do |
2405 |
mss_f="$f"; |
mss_f="$f"; |
2406 |
if obj mss_f is_file; |
if obj mss_f is_file |
2407 |
then |
then |
2408 |
if is_yes "${mss_got_one}"; |
if is_yes "${mss_got_one}" |
2409 |
then |
then |
2410 |
register_file "${mss_f}"; |
register_file "${mss_f}"; |
2411 |
elif obj _MAN_ALL is_yes; |
elif obj _MAN_ALL is_yes |
2412 |
then |
then |
2413 |
man_register_file "${mss_f}" "${mss_name}"; |
man_register_file "${mss_f}" "${mss_name}"; |
2414 |
else |
else |
2435 |
for d |
for d |
2436 |
do |
do |
2437 |
mss_dir="$(dirname_append $d man${mss_section}${mss_ext})"; |
mss_dir="$(dirname_append $d man${mss_section}${mss_ext})"; |
2438 |
if obj mss_dir is_dir; |
if obj mss_dir is_dir |
2439 |
then |
then |
2440 |
mss_prefix=\ |
mss_prefix=\ |
2441 |
"$(dirname_append "${mss_dir}" "${mss_name}.${mss_section}")"; |
"$(dirname_append "${mss_dir}" "${mss_name}.${mss_section}")"; |
2442 |
mss_files="$( eval ls "${mss_prefix}"'*' 2>${_NULL_DEV} | |
mss_files="$( eval ls "${mss_prefix}"'*' 2>${_NULL_DEV} | |
2443 |
sed -e '\|not found|s|.*||' |
sed -e '\|not found|s|.*||' |
2444 |
)"; |
)"; |
2445 |
if obj mss_files is_not_empty; |
if obj mss_files is_not_empty |
2446 |
then |
then |
2447 |
# for f in $mss_files |
# for f in $mss_files |
2448 |
for f in $(eval set x ${mss_files}; shift; echo "$@") |
for f in $(eval set x ${mss_files}; shift; echo "$@") |
2449 |
do |
do |
2450 |
mss_f="$f"; |
mss_f="$f"; |
2451 |
if obj mss_f is_file; |
if obj mss_f is_file |
2452 |
then |
then |
2453 |
if is_yes "${mss_got_one}"; |
if is_yes "${mss_got_one}" |
2454 |
then |
then |
2455 |
register_file "${mss_f}"; |
register_file "${mss_f}"; |
2456 |
elif obj _MAN_ALL is_yes; |
elif obj _MAN_ALL is_yes |
2457 |
then |
then |
2458 |
man_register_file "${mss_f}" "${mss_name}"; |
man_register_file "${mss_f}" "${mss_name}"; |
2459 |
else |
else |
2478 |
for d |
for d |
2479 |
do |
do |
2480 |
mss_dir="$(dirname_append "$d" "man${mss_section}")"; |
mss_dir="$(dirname_append "$d" "man${mss_section}")"; |
2481 |
if obj mss_dir is_dir; |
if obj mss_dir is_dir |
2482 |
then |
then |
2483 |
mss_prefix="$(dirname_append "${mss_dir}" \ |
mss_prefix="$(dirname_append "${mss_dir}" \ |
2484 |
"${mss_name}.${mss_section}${mss_ext}")"; |
"${mss_name}.${mss_section}${mss_ext}")"; |
2485 |
mss_files="$(eval ls "${mss_prefix}"'*' 2>${_NULL_DEV} | |
mss_files="$(eval ls "${mss_prefix}"'*' 2>${_NULL_DEV} | |
2486 |
sed -e '\|not found|s|.*||' |
sed -e '\|not found|s|.*||' |
2487 |
)"; |
)"; |
2488 |
if obj mss_files is_not_empty; |
if obj mss_files is_not_empty |
2489 |
then |
then |
2490 |
# for f in $mss_files |
# for f in $mss_files |
2491 |
for f in $(eval set x ${mss_files}; shift; echo "$@") |
for f in $(eval set x ${mss_files}; shift; echo "$@") |
2492 |
do |
do |
2493 |
mss_f="$f"; |
mss_f="$f"; |
2494 |
if obj mss_f is_file; |
if obj mss_f is_file |
2495 |
then |
then |
2496 |
if is_yes "${mss_got_one}"; |
if is_yes "${mss_got_one}" |
2497 |
then |
then |
2498 |
register_file "${mss_f}"; |
register_file "${mss_f}"; |
2499 |
elif obj _MAN_ALL is_yes; |
elif obj _MAN_ALL is_yes |
2500 |
then |
then |
2501 |
man_register_file "${mss_f}" "${mss_name}"; |
man_register_file "${mss_f}" "${mss_name}"; |
2502 |
else |
else |
2518 |
fi; |
fi; |
2519 |
done; |
done; |
2520 |
fi; |
fi; |
2521 |
if obj _MAN_ALL is_yes && is_yes "${mss_got_one}"; |
if obj _MAN_ALL is_yes && is_yes "${mss_got_one}" |
2522 |
then |
then |
2523 |
eval ${_UNSET} mss_dir; |
eval ${_UNSET} mss_dir; |
2524 |
eval ${_UNSET} mss_ext; |
eval ${_UNSET} mss_ext; |
2570 |
{ |
{ |
2571 |
func_check main_man_setup = 0 "$@"; |
func_check main_man_setup = 0 "$@"; |
2572 |
|
|
2573 |
if obj _MAN_IS_SETUP is_yes; |
if obj _MAN_IS_SETUP is_yes |
2574 |
then |
then |
2575 |
eval "${return_ok}"; |
eval "${return_ok}"; |
2576 |
fi; |
fi; |
2577 |
_MAN_IS_SETUP='yes'; |
_MAN_IS_SETUP='yes'; |
2578 |
|
|
2579 |
if obj _MAN_ENABLE is_not_yes; |
if obj _MAN_ENABLE is_not_yes |
2580 |
then |
then |
2581 |
eval "${return_ok}"; |
eval "${return_ok}"; |
2582 |
fi; |
fi; |
2584 |
# determine basic path for man pages |
# determine basic path for man pages |
2585 |
_MAN_PATH="$(get_first_essential \ |
_MAN_PATH="$(get_first_essential \ |
2586 |
"${_OPT_MANPATH}" "${_MANOPT_PATH}" "${MANPATH}")"; |
"${_OPT_MANPATH}" "${_MANOPT_PATH}" "${MANPATH}")"; |
2587 |
if obj _MAN_PATH is_empty; |
if obj _MAN_PATH is_empty |
2588 |
then |
then |
2589 |
manpath_set_from_path; |
manpath_set_from_path; |
2590 |
else |
else |
2591 |
_MAN_PATH="$(path_clean "${_MAN_PATH}")"; |
_MAN_PATH="$(path_clean "${_MAN_PATH}")"; |
2592 |
fi; |
fi; |
2593 |
if obj _MAN_PATH is_empty; |
if obj _MAN_PATH is_empty |
2594 |
then |
then |
2595 |
if is_prog 'manpath'; |
if is_prog 'manpath' |
2596 |
then |
then |
2597 |
_MAN_PATH="$(manpath 2>${_NULL_DEV})"; # not always available |
_MAN_PATH="$(manpath 2>${_NULL_DEV})"; # not always available |
2598 |
fi; |
fi; |
2599 |
fi; |
fi; |
2600 |
if obj _MAN_PATH is_empty; |
if obj _MAN_PATH is_empty |
2601 |
then |
then |
2602 |
_MAN_ENABLE="no"; |
_MAN_ENABLE="no"; |
2603 |
eval "${return_ok}"; |
eval "${return_ok}"; |
2604 |
fi; |
fi; |
2605 |
|
|
2606 |
_MAN_ALL="$(get_first_essential "${_OPT_ALL}" "${_MANOPT_ALL}")"; |
_MAN_ALL="$(get_first_essential "${_OPT_ALL}" "${_MANOPT_ALL}")"; |
2607 |
if obj _MAN_ALL is_empty; |
if obj _MAN_ALL is_empty |
2608 |
then |
then |
2609 |
_MAN_ALL='no'; |
_MAN_ALL='no'; |
2610 |
fi; |
fi; |
2625 |
*) |
*) |
2626 |
_MAN_LANG="${ms_lang}"; |
_MAN_LANG="${ms_lang}"; |
2627 |
# get first two characters of $ms_lang |
# get first two characters of $ms_lang |
2628 |
_MAN_LANG2="$(echo x"${ms_lang}" | sed -e 's/^x\(..\).*$/\1/')"; |
_MAN_LANG2="$(echo1 "${ms_lang}" | sed -e 's/^\(..\).*$/\1/')"; |
2629 |
;; |
;; |
2630 |
esac; |
esac; |
2631 |
# from now on, use only $_LANG, forget about $_OPT_LANG, $LC_*. |
# from now on, use only $_LANG, forget about $_OPT_LANG, $LC_*. |
2634 |
|
|
2635 |
_MAN_SEC="$(get_first_essential \ |
_MAN_SEC="$(get_first_essential \ |
2636 |
"${_OPT_SECT}" "${_MANOPT_SEC}" "${MANSEC}")"; |
"${_OPT_SECT}" "${_MANOPT_SEC}" "${MANSEC}")"; |
2637 |
if obj _MAN_PATH is_empty; |
if obj _MAN_PATH is_empty |
2638 |
then |
then |
2639 |
_MAN_ENABLE="no"; |
_MAN_ENABLE="no"; |
2640 |
eval ${_UNSET} ms_lang; |
eval ${_UNSET} ms_lang; |
2671 |
manpath_add_lang_sys() |
manpath_add_lang_sys() |
2672 |
{ |
{ |
2673 |
func_check manpath_add_lang_sys = 0 "$@"; |
func_check manpath_add_lang_sys = 0 "$@"; |
2674 |
if obj _MAN_PATH is_empty; |
if obj _MAN_PATH is_empty |
2675 |
then |
then |
2676 |
eval "${return_ok}"; |
eval "${return_ok}"; |
2677 |
fi; |
fi; |
2715 |
do |
do |
2716 |
_mals_dir="$(dirname_append "${_mals_parent}" "$d")"; |
_mals_dir="$(dirname_append "${_mals_parent}" "$d")"; |
2717 |
if obj _mals_res path_not_contains "${_mals_dir}" && \ |
if obj _mals_res path_not_contains "${_mals_dir}" && \ |
2718 |
obj _mals_dir is_dir; |
obj _mals_dir is_dir |
2719 |
then |
then |
2720 |
_mals_res="${_mals_res}:${_mals_dir}"; |
_mals_res="${_mals_res}:${_mals_dir}"; |
2721 |
fi; |
fi; |
2722 |
done; |
done; |
2723 |
if path_not_contains "${_mals_res}" "${_mals_parent}"; |
if path_not_contains "${_mals_res}" "${_mals_parent}" |
2724 |
then |
then |
2725 |
_mals_res="${_mals_res}:${_mals_parent}"; |
_mals_res="${_mals_res}:${_mals_parent}"; |
2726 |
fi; |
fi; |
2754 |
msfp_manpath=''; |
msfp_manpath=''; |
2755 |
|
|
2756 |
# get a basic man path from $PATH |
# get a basic man path from $PATH |
2757 |
if obj PATH is_not_empty; |
if obj PATH is_not_empty |
2758 |
then |
then |
2759 |
eval set x "$(path_split "${PATH}")"; |
eval set x "$(path_split "${PATH}")"; |
2760 |
shift; |
shift; |
2761 |
for d |
for d |
2762 |
do |
do |
2763 |
# delete the final `/bin' part |
# delete the final `/bin' part |
2764 |
msfp_base="$(echo x"$d" | sed -e ' |
msfp_base="$(echo1 "$d" | sed -e 's|//*bin/*$||')"; |
|
s/^x// |
|
|
s|//*bin/*$|| |
|
|
')"; |
|
2765 |
for e in /share/man /man |
for e in /share/man /man |
2766 |
do |
do |
2767 |
msfp_mandir="${msfp_base}$e"; |
msfp_mandir="${msfp_base}$e"; |
2768 |
if test -d "${msfp_mandir}" && test -r "${msfp_mandir}"; |
if test -d "${msfp_mandir}" && test -r "${msfp_mandir}" |
2769 |
then |
then |
2770 |
msfp_manpath="${msfp_manpath}:${msfp_mandir}"; |
msfp_manpath="${msfp_manpath}:${msfp_mandir}"; |
2771 |
fi; |
fi; |
2781 |
/opt/gnome/man /opt/kde/man |
/opt/gnome/man /opt/kde/man |
2782 |
do |
do |
2783 |
msfp_d="$d"; |
msfp_d="$d"; |
2784 |
if obj msfp_manpath path_not_contains "${msfp_d}" && obj mfsp_d is_dir; |
if obj msfp_manpath path_not_contains "${msfp_d}" && obj mfsp_d is_dir |
2785 |
then |
then |
2786 |
msfp_manpath="${msfp_manpath}:${mfsp_d}"; |
msfp_manpath="${msfp_manpath}:${mfsp_d}"; |
2787 |
fi; |
fi; |
2818 |
obj() |
obj() |
2819 |
{ |
{ |
2820 |
func_check obj '>=' 2 "$@"; |
func_check obj '>=' 2 "$@"; |
2821 |
if is_empty "$2"; |
if is_empty "$2" |
2822 |
then |
then |
2823 |
error "obj(): function name is empty." |
error "obj(): function name is empty." |
2824 |
else |
else |
2850 |
obj_data() |
obj_data() |
2851 |
{ |
{ |
2852 |
func_check obj '=' 1 "$@"; |
func_check obj '=' 1 "$@"; |
2853 |
if is_empty "$1"; |
if is_empty "$1" |
2854 |
then |
then |
2855 |
error "obj_data(): object name is empty." |
error "obj_data(): object name is empty." |
2856 |
fi; |
fi; |
2857 |
eval od_res='"${'$1'}"'; |
eval od_res='"${'$1'}"'; |
2858 |
cat <<EOF |
obj od_res echo1; |
|
${od_res} |
|
|
EOF |
|
2859 |
eval ${_UNSET} od_res; |
eval ${_UNSET} od_res; |
2860 |
eval "${return_ok}"; |
eval "${return_ok}"; |
2861 |
} |
} |
2878 |
obj_from_output() |
obj_from_output() |
2879 |
{ |
{ |
2880 |
func_check obj_from_output '>=' 2 "$@"; |
func_check obj_from_output '>=' 2 "$@"; |
2881 |
if is_empty "$1"; |
if is_empty "$1" |
2882 |
then |
then |
2883 |
error "res(): variable name is empty."; |
error "res(): variable name is empty."; |
2884 |
elif is_empty "$2"; |
elif is_empty "$2" |
2885 |
then |
then |
2886 |
error "res(): function name is empty." |
error "res(): function name is empty." |
2887 |
else |
else |
2906 |
obj_set() |
obj_set() |
2907 |
{ |
{ |
2908 |
func_check obj_set '=' 2 "$@"; |
func_check obj_set '=' 2 "$@"; |
2909 |
if is_empty "$1"; |
if is_empty "$1" |
2910 |
then |
then |
2911 |
error "obj_set(): object name is empty." |
error "obj_set(): object name is empty." |
2912 |
fi; |
fi; |
2929 |
|
|
2930 |
# replace multiple colons by a single colon `:' |
# replace multiple colons by a single colon `:' |
2931 |
# remove leading and trailing colons |
# remove leading and trailing colons |
2932 |
echo x"$1" | sed -e ' |
echo1 "$1" | sed -e ' |
2933 |
s/^x:*// |
s/^:*// |
2934 |
s/:::*/:/g |
s/:::*/:/g |
2935 |
s/:*$// |
s/:*$// |
2936 |
'; |
'; |
2951 |
path_clean() |
path_clean() |
2952 |
{ |
{ |
2953 |
func_check path_clean = 1 "$@"; |
func_check path_clean = 1 "$@"; |
2954 |
if is_not_equal "$#" 1; |
if is_not_equal "$#" 1 |
2955 |
then |
then |
2956 |
error 'path_clean() needs 1 argument.'; |
error 'path_clean() needs 1 argument.'; |
2957 |
fi; |
fi; |
2964 |
pc_i="$i"; |
pc_i="$i"; |
2965 |
if obj pc_i is_not_empty \ |
if obj pc_i is_not_empty \ |
2966 |
&& obj pc_res path_not_contains "${pc_i}" \ |
&& obj pc_res path_not_contains "${pc_i}" \ |
2967 |
&& obj pc_i is_dir; |
&& obj pc_i is_dir |
2968 |
then |
then |
2969 |
case "${pc_i}" in |
case "${pc_i}" in |
2970 |
?*/) pc_res="${pc_res}$(dirname_chop "${pc_i}")"; ;; |
?*/) pc_res="${pc_res}$(dirname_chop "${pc_i}")"; ;; |
2975 |
eval ${_UNSET} pc_arg; |
eval ${_UNSET} pc_arg; |
2976 |
eval ${_UNSET} pc_i; |
eval ${_UNSET} pc_i; |
2977 |
eval ${_UNSET} pc_res; |
eval ${_UNSET} pc_res; |
2978 |
if path_chop "${pc_res}"; |
if path_chop "${pc_res}" |
2979 |
then |
then |
2980 |
eval "${return_ok}"; |
eval "${return_ok}"; |
2981 |
else |
else |
3017 |
path_not_contains() |
path_not_contains() |
3018 |
{ |
{ |
3019 |
func_check path_not_contains = 2 "$@"; |
func_check path_not_contains = 2 "$@"; |
3020 |
if path_contains "$1" "$2"; |
if path_contains "$1" "$2" |
3021 |
then |
then |
3022 |
eval "${return_no}"; |
eval "${return_no}"; |
3023 |
else |
else |
3058 |
register_file() |
register_file() |
3059 |
{ |
{ |
3060 |
func_check register_file = 1 "$@"; |
func_check register_file = 1 "$@"; |
3061 |
if is_empty "$1"; |
if is_empty "$1" |
3062 |
then |
then |
3063 |
error 'register_file(): file name is empty'; |
error 'register_file(): file name is empty'; |
3064 |
fi; |
fi; |
3065 |
if is_equal "$1" '-'; |
if is_equal "$1" '-' |
3066 |
then |
then |
3067 |
to_tmp "${_TMP_STDIN}"; |
to_tmp "${_TMP_STDIN}"; |
3068 |
register_title 'stdin'; |
register_title 'stdin'; |
3085 |
# |
# |
3086 |
register_title() |
register_title() |
3087 |
{ |
{ |
3088 |
func_check register_title = 1 "$@"; |
func_check register_title '=' 1 "$@"; |
3089 |
if is_empty "$1"; |
if is_empty "$1" |
3090 |
then |
then |
3091 |
eval "${return_ok}"; |
eval "${return_ok}"; |
3092 |
fi; |
fi; |
3093 |
rt_title="$(base_name "$1")"; # remove directory part |
rt_title="$(base_name "$1")"; # remove directory part |
3094 |
|
|
3095 |
|
# replace space characters by `_' |
3096 |
|
rt_title="$(echo1 "${rt_title}" | sed -e 's/[ ]/_/g')"; |
3097 |
# remove extension `.gz' |
# remove extension `.gz' |
3098 |
rt_title="$(echo x"${rt_title}" | sed -e ' |
rt_title="$(echo1 "${rt_title}" | sed -e 's/\.gz$//')"; |
|
s/^x// |
|
|
s/\.gz$// |
|
|
')"; |
|
3099 |
# remove extension `.Z' |
# remove extension `.Z' |
3100 |
rt_title="$(echo x"${rt_title}" | sed -e ' |
rt_title="$(echo1 "${rt_title}" | sed -e 's/\.Z$//')"; |
|
s/^x// |
|
|
s/\.Z$// |
|
|
')"; |
|
3101 |
|
|
3102 |
if obj rt_title is_empty; |
if obj rt_title is_empty |
3103 |
then |
then |
3104 |
eval "${return_ok}"; |
eval "${return_ok}"; |
3105 |
fi; |
fi; |
3119 |
|
|
3120 |
|
|
3121 |
######################################################################## |
######################################################################## |
3122 |
|
# rm_file (<file_name>) |
3123 |
|
# |
3124 |
|
# Remove file if $_DEBUG_KEEP_FILES allows it. |
3125 |
|
# |
3126 |
|
# Globals: $_DEBUG_KEEP_FILES |
3127 |
|
# |
3128 |
|
rm_file() |
3129 |
|
{ |
3130 |
|
func_check rm_file '=' 1 "$@"; |
3131 |
|
if is_file "$1" |
3132 |
|
then |
3133 |
|
rm -f "$1" >${_NULL_DEV} 2>&1; |
3134 |
|
fi; |
3135 |
|
if is_existing "$1" |
3136 |
|
then |
3137 |
|
eval "${return_bad}"; |
3138 |
|
else |
3139 |
|
eval "${return_good}"; |
3140 |
|
fi; |
3141 |
|
} |
3142 |
|
|
3143 |
|
|
3144 |
|
######################################################################## |
3145 |
|
# rm_file_with_debug (<file_name>) |
3146 |
|
# |
3147 |
|
# Remove file if $_DEBUG_KEEP_FILES allows it. |
3148 |
|
# |
3149 |
|
# Globals: $_DEBUG_KEEP_FILES |
3150 |
|
# |
3151 |
|
rm_file_with_debug() |
3152 |
|
{ |
3153 |
|
func_check rm_file_with_debug '=' 1 "$@"; |
3154 |
|
if obj _DEBUG_KEEP_FILES is_not_yes |
3155 |
|
then |
3156 |
|
if is_file "$1" |
3157 |
|
then |
3158 |
|
rm -f "$1" >${_NULL_DEV} 2>&1; |
3159 |
|
fi; |
3160 |
|
fi; |
3161 |
|
if is_existing "$1" |
3162 |
|
then |
3163 |
|
eval "${return_bad}"; |
3164 |
|
else |
3165 |
|
eval "${return_good}"; |
3166 |
|
fi; |
3167 |
|
} |
3168 |
|
|
3169 |
|
|
3170 |
|
######################################################################## |
3171 |
|
# rm_tree (<dir_name>) |
3172 |
|
# |
3173 |
|
# Remove file if $_DEBUG_KEEP_FILES allows it. |
3174 |
|
# |
3175 |
|
# Globals: $_DEBUG_KEEP_FILES |
3176 |
|
# |
3177 |
|
rm_tree() |
3178 |
|
{ |
3179 |
|
func_check rm_tree '=' 1 "$@"; |
3180 |
|
if is_existing "$1" |
3181 |
|
then |
3182 |
|
rm -f -r "$1" >${_NULL_DEV} 2>&1; |
3183 |
|
fi; |
3184 |
|
if is_existing "$1" |
3185 |
|
then |
3186 |
|
eval "${return_bad}"; |
3187 |
|
else |
3188 |
|
eval "${return_good}"; |
3189 |
|
fi; |
3190 |
|
} |
3191 |
|
|
3192 |
|
|
3193 |
|
######################################################################## |
3194 |
# save_stdin () |
# save_stdin () |
3195 |
# |
# |
3196 |
# Store standard input to temporary file (with decompression). |
# Store standard input to temporary file (with decompression). |
3197 |
# |
# |
3198 |
# Variable prefix: ss |
# Variable prefix: ss |
3199 |
# |
# |
3200 |
if obj _HAS_COMPRESSION is_yes; |
if obj _HAS_COMPRESSION is_yes |
3201 |
then |
then |
3202 |
save_stdin() |
save_stdin() |
3203 |
{ |
{ |
3204 |
func_check save_stdin = 0 "$@"; |
func_check save_stdin '=' 0 "$@"; |
3205 |
ss_f="${_TMP_DIR}"/INPUT; |
ss_f="${_TMP_DIR}"/INPUT; |
3206 |
cat >"${ss_f}"; |
cat >"${ss_f}"; |
3207 |
cat_z "${ss_f}" >"${_TMP_STDIN}"; |
cat_z "${ss_f}" >"${_TMP_STDIN}"; |
3208 |
rm -f "${ss_f}"; |
rm_file "${ss_f}"; |
3209 |
eval ${_UNSET} ss_f; |
eval ${_UNSET} ss_f; |
3210 |
eval "${return_ok}"; |
eval "${return_ok}"; |
3211 |
} |
} |
3233 |
# |
# |
3234 |
string_contains() |
string_contains() |
3235 |
{ |
{ |
3236 |
func_check string_contains = 2 "$@"; |
func_check string_contains '=' 2 "$@"; |
3237 |
case "$1" in |
case "$1" in |
3238 |
*"$2"*) |
*"$2"*) |
3239 |
eval "${return_yes}"; |
eval "${return_yes}"; |
3256 |
# |
# |
3257 |
string_not_contains() |
string_not_contains() |
3258 |
{ |
{ |
3259 |
func_check string_not_contains = 2 "$@"; |
func_check string_not_contains '=' 2 "$@"; |
3260 |
if string_contains "$1" "$2"; |
if string_contains "$1" "$2" |
3261 |
then |
then |
3262 |
eval "${return_no}"; |
eval "${return_no}"; |
3263 |
else |
else |
3305 |
# different names from the output file. |
# different names from the output file. |
3306 |
tc_tmp="${_TMP_DIR}/,$1"; |
tc_tmp="${_TMP_DIR}/,$1"; |
3307 |
: >"${tc_tmp}" |
: >"${tc_tmp}" |
3308 |
cat <<EOF |
obj tc_tmp echo1; |
|
${tc_tmp} |
|
|
EOF |
|
3309 |
eval ${_UNSET} tc_tmp; |
eval ${_UNSET} tc_tmp; |
3310 |
eval "${return_ok}"; |
eval "${return_ok}"; |
3311 |
} |
} |
3319 |
to_tmp() |
to_tmp() |
3320 |
{ |
{ |
3321 |
func_check to_tmp = 1 "$@"; |
func_check to_tmp = 1 "$@"; |
3322 |
if is_file "$1"; |
if is_file "$1" |
3323 |
then |
then |
3324 |
if obj _OPT_LOCATION is_yes; |
if obj _OPT_LOCATION is_yes |
3325 |
then |
then |
3326 |
echo2 "$1"; |
echo2 "$1"; |
3327 |
fi; |
fi; |
3328 |
if obj _OPT_WHATIS is_yes; |
if obj _OPT_WHATIS is_yes |
3329 |
then |
then |
3330 |
what_is "$1" >>"${_TMP_CAT}"; |
what_is "$1" >>"${_TMP_CAT}"; |
3331 |
else |
else |
3350 |
{ |
{ |
3351 |
func_check trap_clean = 0 "$@"; |
func_check trap_clean = 0 "$@"; |
3352 |
# for i in $_ALL_EXIT |
# for i in $_ALL_EXIT |
3353 |
for i in $(eval set x ${_ALL_EXIT}; shift; echo "$@") |
for i in $(eval set x "${_ALL_EXIT}"; shift; echo "$@") |
3354 |
do |
do |
3355 |
trap "" "$i" 2>${_NULL_DEV} || :; |
trap "" "$i" 2>${_NULL_DEV} || :; |
3356 |
done; |
done; |
3370 |
{ |
{ |
3371 |
func_check trap_set = 1 "$@"; |
func_check trap_set = 1 "$@"; |
3372 |
# for i in $_ALL_EXIT |
# for i in $_ALL_EXIT |
3373 |
for i in $(eval set x ${_ALL_EXIT}; shift; echo "$@") |
for i in $(eval set x "${_ALL_EXIT}"; shift; echo "$@") |
3374 |
do |
do |
3375 |
trap "$1" "$i" 2>${_NULL_DEV} || :; |
trap "$1" "$i" 2>${_NULL_DEV} || :; |
3376 |
done; |
done; |
3388 |
func_check usage = 0 "$@"; |
func_check usage = 0 "$@"; |
3389 |
echo; |
echo; |
3390 |
version; |
version; |
3391 |
echo 'Usage: '"${_PROGRAM_NAME}"' [option]... [filespec]...'; |
echo 'Usage: groffer [option]... [filespec]...'; |
3392 |
cat <<EOF |
cat <<EOF |
3393 |
|
|
3394 |
Display roff files, standard input, and/or Unix manual pages with a X |
Display roff files, standard input, and/or Unix manual pages with a X |
3404 |
"name" man page "name" in first section found |
"name" man page "name" in first section found |
3405 |
and some more (see groffer(1) for details). |
and some more (see groffer(1) for details). |
3406 |
|
|
3407 |
-h --help print this usage message. |
-h --help print this usage message. |
3408 |
-Q --source output as roff source. |
-Q --source output as roff source. |
3409 |
-T --device=name pass to groff using output device "name". |
-T --device=name pass to groff using output device "name". |
3410 |
-v --version print version information. |
-v --version print version information. |
3411 |
-V display the groff execution pipe instead of formatting. |
-V display the groff execution pipe instead of formatting. |
3412 |
-X --X --x display with "gxditview" using groff -X. |
-X display with "gxditview" using groff -X. |
3413 |
-Z --ditroff --intermediate-output |
-Z --ditroff --intermediate-output |
3414 |
generate groff intermediate output without |
generate groff intermediate output without |
3415 |
post-processing and viewing, like groff -Z. |
post-processing and viewing, like groff -Z. |
3416 |
All other short options are interpreted as "groff" formatting options. |
All other short options are interpreted as "groff" formatting options. |
3417 |
|
|
3418 |
The most important groffer long options are |
The most important groffer long options are |
3419 |
|
|
3420 |
--apropos=name start man's "apropos" program for "name". |
--apropos=name start man's "apropos" program for "name". |
3421 |
--apropos-data=name |
--apropos-data=name |
3422 |
"apropos" for "name" in man's data sections 4, 5, 7. |
"apropos" for "name" in man's data sections 4, 5, 7. |
3423 |
--apropos-devel=name |
--apropos-devel=name |
3424 |
"apropos" for "name" in development sections 2, 3, 9. |
"apropos" for "name" in development sections 2, 3, 9. |
3425 |
--apropos-progs=name |
--apropos-progs=name |
3426 |
"apropos" for "name" in man's program sections 1, 6, 8. |
"apropos" for "name" in man's program sections 1, 6, 8. |
3427 |
--auto choose mode automatically from the default mode list. |
--auto choose mode automatically from the default mode list. |
3428 |
--default reset all options to the default value. |
--default reset all options to the default value. |
3429 |
--default-modes=mode1,mode2,... |
--default-modes=mode1,mode2,... |
3430 |
set sequence of automatically tried modes. |
set sequence of automatically tried modes. |
3431 |
--dvi display in a viewer for TeX device independent format. |
--dvi display in a viewer for TeX device independent format. |
3432 |
--dvi-viewer choose the viewer program for dvi mode. |
--dvi-viewer=prog choose the viewer program for dvi mode. |
3433 |
--groff process like groff, disable viewing features. |
--groff process like groff, disable viewing features. |
3434 |
--help display this helping output. |
--help display this helping output. |
3435 |
--html --www display in a web browser. |
--html display in a web browser. |
3436 |
--html-viewer choose the web browser for www mode. |
--html-viewer=program |
3437 |
--man check file parameters first whether they are man pages. |
choose the web browser for html mode. |
3438 |
|
--man check file parameters first whether they are man pages. |
3439 |
--mode=auto|dvi|groff|html|pdf|ps|source|text|tty|www|x|X |
--mode=auto|dvi|groff|html|pdf|ps|source|text|tty|www|x|X |
3440 |
choose display mode. |
choose display mode. |
3441 |
--no-man disable man-page facility. |
--no-man disable man-page facility. |
3442 |
--pager=program preset the paging program for tty mode. |
--pager=program preset the paging program for tty mode. |
3443 |
--pdf display in a PDF viewer. |
--pdf display in a PDF viewer. |
3444 |
--pdf-viewer choose the viewer program for pdf mode. |
--pdf-viewer=prog choose the viewer program for pdf mode. |
3445 |
--ps display in a Postscript viewer. |
--ps display in a Postscript viewer. |
3446 |
--ps-viewer choose the viewer program for ps mode. |
--ps-viewer=prog choose the viewer program for ps mode. |
3447 |
--shell specify shell under which to run this program. |
--shell=program specify shell under which to run groffer2.sh. |
3448 |
--text output in a text device without a pager. |
--text output in a text device without a pager. |
3449 |
--tty display with a pager on text terminal even when in X. |
--tty display with a pager on text terminal even when in X. |
3450 |
--www-viewer same as --html-viewer |
--tty-viewer=prog select a pager for tty mode; same as --pager. |
3451 |
--x-viewer choose viewer program for x mode (X mode). |
--www same as --html. |
3452 |
--X-viewer same as "--xviewer". |
--www-viewer=prog same as --html-viewer |
3453 |
|
--x --X display with "gxditview" using an X* device. |
3454 |
|
--x-viewer=prog choose viewer program for x mode (X mode). |
3455 |
|
--X-viewer=prog same as "--xviewer". |
3456 |
|
|
3457 |
The usual X Windows toolkit options transformed into GNU long options |
The usual X Windows toolkit options transformed into GNU long options |
3458 |
--background=color, --bd=size, --bg=color, --bordercolor=color, |
--background=color, --bd=size, --bg=color, --bordercolor=color, |
3478 |
version() |
version() |
3479 |
{ |
{ |
3480 |
func_check version = 0 "$@"; |
func_check version = 0 "$@"; |
3481 |
echo2 "${_PROGRAM_NAME} ${_PROGRAM_VERSION} of ${_LAST_UPDATE}"; |
echo2 "groffer ${_PROGRAM_VERSION} of ${_LAST_UPDATE}"; |
3482 |
# also display groff's version, but not the called subprograms |
# also display groff's version, but not the called subprograms |
3483 |
groff -v 2>&1 | sed -e '/^ *$/q' | sed -e '1s/^/is part of /' >&2; |
groff -v 2>&1 | sed -e '/^ *$/q' | sed -e '1s/^/is part of /' >&2; |
3484 |
eval "${return_ok}"; |
eval "${return_ok}"; |
3507 |
what_is() |
what_is() |
3508 |
{ |
{ |
3509 |
func_check what_is = 1 "$@"; |
func_check what_is = 1 "$@"; |
3510 |
if is_not_file "$1"; |
if is_not_file "$1" |
3511 |
then |
then |
3512 |
error "what_is(): argument is not a readable file." |
error "what_is(): argument is not a readable file." |
3513 |
fi; |
fi; |
3514 |
wi_dot='^\.['"${_SPACE}${_TAB}"']*'; |
wi_dot='^\.['"${_SP}${_TAB}"']*'; |
3515 |
cat <<EOF |
cat <<EOF |
3516 |
.br |
.br |
3517 |
$1: |
$1: |
3520 |
# grep the line containing `.TH' macro, if any |
# grep the line containing `.TH' macro, if any |
3521 |
wi_res="$(cat_z "$1" | sed -e '/'"${wi_dot}"'TH /p |
wi_res="$(cat_z "$1" | sed -e '/'"${wi_dot}"'TH /p |
3522 |
d')"; |
d')"; |
3523 |
if obj wi_res is_not_empty; |
if obj wi_res is_not_empty |
3524 |
then # traditional man style |
then # traditional man style |
3525 |
# get the text between the first and the second `.SH' macro, by |
# get the text between the first and the second `.SH' macro, by |
3526 |
# - delete up to first .SH; |
# - delete up to first .SH; |
3537 |
# grep the line containing `.Dd' macro, if any |
# grep the line containing `.Dd' macro, if any |
3538 |
wi_res="$(cat_z "$1" | sed -e '/'"${wi_dot}"'Dd /p |
wi_res="$(cat_z "$1" | sed -e '/'"${wi_dot}"'Dd /p |
3539 |
d')"; |
d')"; |
3540 |
if obj wi_res is_not_empty; |
if obj wi_res is_not_empty |
3541 |
then # BSD doc style |
then # BSD doc style |
3542 |
# get the text between the first and the second `.Nd' macro, by |
# get the text between the first and the second `.Nd' macro, by |
3543 |
# - delete up to first .Nd; |
# - delete up to first .Nd; |
3573 |
{ |
{ |
3574 |
func_check where_is '>=' 1 "$@"; |
func_check where_is '>=' 1 "$@"; |
3575 |
w_arg="$1"; |
w_arg="$1"; |
3576 |
if obj w_arg is_empty; |
if obj w_arg is_empty |
3577 |
then |
then |
3578 |
eval ${_UNSET} w_arg; |
eval ${_UNSET} w_arg; |
3579 |
eval "${return_bad}"; |
eval "${return_bad}"; |
3582 |
/*) |
/*) |
3583 |
eval ${_UNSET} w_arg; |
eval ${_UNSET} w_arg; |
3584 |
eval ${_UNSET} w_file; |
eval ${_UNSET} w_file; |
3585 |
if test -f "${w_arg}" && test -x "${w_arg}"; |
if test -f "${w_arg}" && test -x "${w_arg}" |
3586 |
then |
then |
3587 |
eval "${return_ok}"; |
eval "${return_ok}"; |
3588 |
else |
else |
3598 |
*/) w_file=${p}${w_arg}; ;; |
*/) w_file=${p}${w_arg}; ;; |
3599 |
*) w_file=${p}/${w_arg}; ;; |
*) w_file=${p}/${w_arg}; ;; |
3600 |
esac; |
esac; |
3601 |
if test -f "${w_file}" && test -x "${w_file}"; |
if test -f "${w_file}" && test -x "${w_file}" |
3602 |
then |
then |
3603 |
cat <<EOF |
obj w_file echo1; |
|
${w_file} |
|
|
EOF |
|
3604 |
eval ${_UNSET} w_arg; |
eval ${_UNSET} w_arg; |
3605 |
eval ${_UNSET} w_file; |
eval ${_UNSET} w_file; |
3606 |
eval "${return_ok}"; |
eval "${return_ok}"; |
3630 |
# sequence they are called in the main() function. |
# sequence they are called in the main() function. |
3631 |
|
|
3632 |
|
|
|
landmark '13: main_init()'; |
|
3633 |
####################################################################### |
####################################################################### |
3634 |
# main_init () |
# main_init () |
3635 |
# |
# |
3653 |
do |
do |
3654 |
mi_dir="$d"; |
mi_dir="$d"; |
3655 |
if obj mi_dir is_empty || obj mi_dir is_not_dir || \ |
if obj mi_dir is_empty || obj mi_dir is_not_dir || \ |
3656 |
obj mi_dir is_not_writable; |
obj mi_dir is_not_writable |
3657 |
then |
then |
3658 |
continue; |
continue; |
3659 |
fi; |
fi; |
3666 |
_TMP_DIR="${mi_dir}"'/'; |
_TMP_DIR="${mi_dir}"'/'; |
3667 |
;; |
;; |
3668 |
esac; |
esac; |
3669 |
_TMP_DIR="${_TMP_DIR}${_PROGRAM_NAME}${_PROCESS_ID}"; |
_TMP_DIR="${_TMP_DIR}groffer${_PROCESS_ID}"; |
3670 |
if obj _TMP_DIR is_existing; |
if obj _TMP_DIR rm_tree |
3671 |
then |
then |
3672 |
eval rm -f -r "'${_TMP_DIR}'" >${_NULL_DEV} 2>&1; |
: |
3673 |
if obj _TMP_DIR is_existing; |
else |
3674 |
then |
mi_tdir_="${_TMP_DIR}"_; |
3675 |
mi_tdir_="${_TMP_DIR}"_; |
mi_n=1; |
3676 |
mi_n=1; |
mi_tdir_n="${mi_tdir_}${mi_n}"; |
3677 |
mi_tdir_n="${mi_tdir_}${mi_n}"; |
while obj mi_tdir_n is_existing |
3678 |
while obj mi_tdir_n is_existing; |
do |
3679 |
do |
if obj mi_tdir_n rm_tree |
3680 |
eval rm -f -r "'${mi_tdir_n}'" >${_NULL_DEV} 2>&1; |
then |
3681 |
if obj mi_tdir_n is_existing; |
# directory could not be removed |
3682 |
then |
mi_n="$(expr "${mi_n}" + 1)"; |
3683 |
# directory could not be removed |
mi_tdir_n="${mi_tdir_}${mi_n}"; |
3684 |
mi_n="$(expr "${mi_n}" + 1)"; |
continue; |
3685 |
mi_tdir_n="${mi_tdir_}${mi_n}"; |
fi; |
3686 |
continue; |
done; |
3687 |
fi; |
_TMP_DIR="${mi_tdir_n}"; |
|
done; |
|
|
_TMP_DIR="${mi_tdir_n}"; |
|
|
fi; |
|
3688 |
fi; |
fi; |
3689 |
eval mkdir "${_TMP_DIR}"; |
eval mkdir "${_TMP_DIR}"; |
3690 |
if is_not_equal "$?" 0; |
if is_not_equal "$?" 0 |
3691 |
then |
then |
3692 |
if obj _TMP_DIR is_existing; |
obj _TMP_DIR rm_tree; |
|
then |
|
|
eval rm -f -r "'${_TMP_DIR}'" >${_NULL_DEV} 2>&1; |
|
|
fi; |
|
3693 |
_TMP_DIR=''; |
_TMP_DIR=''; |
3694 |
continue; |
continue; |
3695 |
fi; |
fi; |
3696 |
if obj _TMP_DIR is_dir && obj _TMP_DIR is_writable; |
if obj _TMP_DIR is_dir && obj _TMP_DIR is_writable |
3697 |
then |
then |
3698 |
# $_TMP_DIR can now be used as temporary directory |
# $_TMP_DIR can now be used as temporary directory |
3699 |
break; |
break; |
3700 |
fi; |
fi; |
3701 |
if obj _TMP_DIR is_existing; |
obj _TMP_DIR rm_tree; |
|
then |
|
|
rm -f -r "'${_TMP_DIR}'" >${_NULL_DEV} 2>&1; |
|
|
fi; |
|
3702 |
_TMP_DIR=''; |
_TMP_DIR=''; |
3703 |
continue; |
continue; |
3704 |
done; |
done; |
3705 |
if obj _TMP_DIR is_empty; |
if obj _TMP_DIR is_empty |
3706 |
then |
then |
3707 |
error "main_init: \ |
error "main_init: \ |
3708 |
Couldn't create a directory for storing temporary files."; |
Couldn't create a directory for storing temporary files."; |
3711 |
_TMP_CAT="$(tmp_create groffer_cat)"; |
_TMP_CAT="$(tmp_create groffer_cat)"; |
3712 |
_TMP_STDIN="$(tmp_create groffer_input)"; |
_TMP_STDIN="$(tmp_create groffer_input)"; |
3713 |
|
|
|
# groffer configuration files |
|
|
# for f in $_CONF_FILES |
|
|
for f in $(eval set x ${_CONF_FILES}; shift; echo "$@") |
|
|
do |
|
|
mi_file="$f"; |
|
|
if obj mi_file is_file; |
|
|
then |
|
|
echo '_groffer_opt=""' >>${_TMP_CAT}; |
|
|
# collect the lines starting with a minus |
|
|
cat "$mi_file" | sed -e ' |
|
|
/^[ ]*#/d |
|
|
s/^[ ]*\(-.*\)$/_groffer_opt="${_groffer_opt} \1"/ |
|
|
' >>${_TMP_CAT}; |
|
|
# prepend the collected information to $GROFFER_OPT |
|
|
echo 'GROFFER_OPT="${_groffer_opt} ${GROFFER_OPT}"' >>${_TMP_CAT}; |
|
|
fi; |
|
|
done; |
|
|
eval . "${_TMP_CAT}"; |
|
|
_TMP_CAT="$(tmp_create groffer_cat)"; |
|
|
|
|
3714 |
eval ${_UNSET} mi_dir; |
eval ${_UNSET} mi_dir; |
|
eval ${_UNSET} mi_file; |
|
3715 |
eval ${_UNSET} mi_n; |
eval ${_UNSET} mi_n; |
3716 |
eval ${_UNSET} mi_tdir_; |
eval ${_UNSET} mi_tdir_; |
3717 |
eval ${_UNSET} mi_tdir_n; |
eval ${_UNSET} mi_tdir_n; |
3719 |
} # main_init() |
} # main_init() |
3720 |
|
|
3721 |
|
|
|
landmark '14: main_parse_MANOPT()'; |
|
3722 |
######################################################################## |
######################################################################## |
3723 |
# main_parse_MANOPT () |
# main_parse_MANOPT () |
3724 |
# |
# |
3735 |
main_parse_MANOPT() |
main_parse_MANOPT() |
3736 |
{ |
{ |
3737 |
func_check main_parse_MANOPT = 0 "$@"; |
func_check main_parse_MANOPT = 0 "$@"; |
3738 |
mpm_list=''; |
|
3739 |
if obj MANOPT is_not_empty; |
if obj MANOPT is_not_empty |
3740 |
then |
then |
3741 |
MANOPT="$(echo x"${MANOPT}" | sed -e 's/^x'"${_SPACE}${_SPACE}"'*//')"; |
# Delete leading and final spaces |
3742 |
|
MANOPT="$(echo1 "${MANOPT}" | sed -e ' |
3743 |
|
s/^['"${_SP}${_TAB}"']*// |
3744 |
|
s/['"${_SP}${_TAB}"']*$// |
3745 |
|
')"; |
3746 |
fi; |
fi; |
3747 |
if obj MANOPT is_empty; |
if obj MANOPT is_empty |
3748 |
then |
then |
|
eval ${_UNSET} mpm_list; |
|
|
eval ${_UNSET} mpm_opt; |
|
3749 |
eval "${return_ok}"; |
eval "${return_ok}"; |
3750 |
fi; |
fi; |
3751 |
|
|
3752 |
|
mpm_list=''; |
3753 |
# add arguments in $MANOPT by mapping them to groffer options |
# add arguments in $MANOPT by mapping them to groffer options |
3754 |
eval set x "$(list_from_cmdline _OPTS_MANOPT "${MANOPT}")"; |
eval set x "$(list_from_cmdline _OPTS_MANOPT "${MANOPT}")"; |
3755 |
shift; |
shift; |
3756 |
until test "$#" -le 0 || is_equal "$1" '--'; |
until test "$#" -le 0 || is_equal "$1" '--' |
3757 |
do |
do |
3758 |
mpm_opt="$1"; |
mpm_opt="$1"; |
3759 |
shift; |
shift; |
3769 |
shift; |
shift; |
3770 |
;; |
;; |
3771 |
-d|--debug) |
-d|--debug) |
3772 |
list_append mpm_list '--debug'; |
do_nothing; |
3773 |
;; |
;; |
3774 |
-D|--default) |
-D|--default) |
3775 |
# undo all man options so far |
# undo all man options so far |
3790 |
-k|--apropos) |
-k|--apropos) |
3791 |
# groffer's --apropos takes an argument, but man's does not, so |
# groffer's --apropos takes an argument, but man's does not, so |
3792 |
do_nothing; |
do_nothing; |
|
shift; |
|
3793 |
;; |
;; |
3794 |
-l|--local-file) |
-l|--local-file) |
3795 |
list_append mpm_list '--local-file'; |
do_nothing; |
3796 |
;; |
;; |
3797 |
-L|--locale) |
-L|--locale) |
3798 |
list_append mpm_list '--locale' "$1"; |
list_append mpm_list '--locale' "$1"; |
3810 |
do_nothing; |
do_nothing; |
3811 |
shift; |
shift; |
3812 |
;; |
;; |
3813 |
-P|--pager|--tty-viewer) |
-P|--pager) |
3814 |
list_append mpm_list '--pager' "$1"; |
list_append mpm_list '--pager' "$1"; |
3815 |
shift; |
shift; |
3816 |
;; |
;; |
3841 |
list_append mpm_list '--location'; |
list_append mpm_list '--location'; |
3842 |
;; |
;; |
3843 |
-Z|--ditroff) |
-Z|--ditroff) |
3844 |
list_append mpm_list '-Z' "$1"; |
do_nothing; |
|
shift; |
|
3845 |
;; |
;; |
3846 |
# ignore all other options |
# ignore all other options |
3847 |
esac; |
esac; |
3848 |
done; |
done; |
3849 |
# append the 2 lists in $mpm_list and $GROFFER_OPT to $GROFFER_OPT |
|
3850 |
if obj GROFFER_OPT is_empty; |
# prepend $mpm_list to $GROFFER_OPT |
3851 |
|
if obj GROFFER_OPT is_empty |
3852 |
then |
then |
3853 |
GROFFER_OPT="${mpm_list}"; |
GROFFER_OPT="${mpm_list}"; |
3854 |
elif obj mpm_list is_not_empty; |
elif obj mpm_list is_not_empty |
3855 |
then |
then |
3856 |
GROFFER_OPT="${mpm_list} ${GROFFER_OPT}"; |
GROFFER_OPT="${mpm_list} ${GROFFER_OPT}"; |
3857 |
fi; |
fi; |
3858 |
|
|
3859 |
eval ${_UNSET} mpm_list; |
eval ${_UNSET} mpm_list; |
3860 |
eval ${_UNSET} mpm_opt; |
eval ${_UNSET} mpm_opt; |
3861 |
eval "${return_ok}"; |
eval "${return_ok}"; |
3862 |
} # main_parse_MANOPT() |
} # main_parse_MANOPT() |
3863 |
|
|
3864 |
|
|
|
landmark '15: main_parse_args()'; |
|
3865 |
######################################################################## |
######################################################################## |
3866 |
# main_parse_args (<command_line_args>*) |
# main_parse_args (<command_line_args>*) |
3867 |
# |
# |
3872 |
# in: $_OPTS_* |
# in: $_OPTS_* |
3873 |
# out: $_OPT_*, $_ADDOPTS, $_FILEARGS |
# out: $_OPT_*, $_ADDOPTS, $_FILEARGS |
3874 |
# |
# |
3875 |
# Variable prefix: mpa |
# Variable prefix: mpa |
3876 |
# |
# |
3877 |
main_parse_args() |
main_parse_args() |
3878 |
{ |
{ |
3879 |
func_check main_parse_args '>=' 0 "$@"; |
func_check main_parse_args '>=' 0 "$@"; |
|
|
|
3880 |
eval set x "${GROFFER_OPT}" '"$@"'; |
eval set x "${GROFFER_OPT}" '"$@"'; |
3881 |
shift; |
shift; |
3882 |
|
|
3883 |
eval set x "$(list_from_cmdline _OPTS_CMDLINE "$@")"; |
_ALL_PARAMS="$(list_from_cmdline _OPTS_CMDLINE "$@")"; |
3884 |
|
if obj _DEBUG_PRINT_PARAMS is_yes |
3885 |
|
then |
3886 |
|
echo2 "parameters: ${_ALL_PARAMS}"; |
3887 |
|
fi; |
3888 |
|
eval set x "${_ALL_PARAMS}"; |
3889 |
shift; |
shift; |
3890 |
|
|
3891 |
# By the call of `eval', unnecessary quoting was removed. So the |
# By the call of `eval', unnecessary quoting was removed. So the |
3897 |
# Note, the existence of arguments to options has already been checked. |
# Note, the existence of arguments to options has already been checked. |
3898 |
# So a check for `$#' or `--' should not be done for arguments. |
# So a check for `$#' or `--' should not be done for arguments. |
3899 |
|
|
3900 |
until test "$#" -le 0 || is_equal "$1" '--'; |
until test "$#" -le 0 || is_equal "$1" '--' |
3901 |
do |
do |
3902 |
mpa_opt="$1"; # $mpa_opt is fed into the option handler |
mpa_opt="$1"; # $mpa_opt is fed into the option handler |
3903 |
shift; |
shift; |
3929 |
;; |
;; |
3930 |
-?) |
-?) |
3931 |
# delete leading `-' |
# delete leading `-' |
3932 |
mpa_optchar="$(echo x"${mpa_opt}" | sed -e 's/^x-//')"; |
mpa_optchar="$(echo1 "${mpa_opt}" | sed -e 's/^-//')"; |
3933 |
if list_has _OPTS_GROFF_SHORT_NA "${mpa_optchar}"; |
if list_has _OPTS_GROFF_SHORT_NA "${mpa_optchar}" |
3934 |
then |
then |
3935 |
list_append _ADDOPTS_GROFF "${mpa_opt}"; |
list_append _ADDOPTS_GROFF "${mpa_opt}"; |
3936 |
elif list_has _OPTS_GROFF_SHORT_ARG "${mpa_optchar}"; |
elif list_has _OPTS_GROFF_SHORT_ARG "${mpa_optchar}" |
3937 |
then |
then |
3938 |
list_append _ADDOPTS_GROFF "${mpa_opt}" "$1"; |
list_append _ADDOPTS_GROFF "${mpa_opt}" "$1"; |
3939 |
shift; |
shift; |
3946 |
;; |
;; |
3947 |
--apropos) # run `apropos' |
--apropos) # run `apropos' |
3948 |
apropos_run "$1"; |
apropos_run "$1"; |
3949 |
mpa_code="$?"; |
leave "$?"; |
|
clean_up; |
|
|
exit "${mpa_code}"; |
|
3950 |
;; |
;; |
3951 |
--apropos-data) # run `apropos' for data sections |
--apropos-data) # run `apropos' for data sections |
3952 |
apropos_run "$1" | grep '^[^(]*([457][^)]*)'; |
apropos_run "$1" | grep '^[^(]*([457][^)]*)'; |
3953 |
mpa_code="$?"; |
leave "$?"; |
|
clean_up; |
|
|
exit "${mpa_code}"; |
|
3954 |
;; |
;; |
3955 |
--apropos-devel) # run `apropos' for development sections |
--apropos-devel) # run `apropos' for development sections |
3956 |
apropos_run "$1" | grep '^[^(]*([239][^)]*)'; |
apropos_run "$1" | grep '^[^(]*([239][^)]*)'; |
3957 |
mpa_code="$?"; |
leave "$?"; |
|
clean_up; |
|
|
exit "${mpa_code}"; |
|
3958 |
;; |
;; |
3959 |
--apropos-progs) # run `apropos' for program sections |
--apropos-progs) # run `apropos' for program sections |
3960 |
apropos_run "$1" | grep '^[^(]*([168][^)]*)'; |
apropos_run "$1" | grep '^[^(]*([168][^)]*)'; |
3961 |
mpa_code="$?"; |
leave "$?"; |
|
clean_up; |
|
|
exit "${mpa_code}"; |
|
3962 |
;; |
;; |
3963 |
--ascii) |
--ascii) |
3964 |
list_append _ADDOPTS_GROFF '-mtty-char'; |
list_append _ADDOPTS_GROFF '-mtty-char'; |
3965 |
if obj _OPT_MODE is_empty; |
if obj _OPT_MODE is_empty |
3966 |
then |
then |
3967 |
_OPT_MODE='text'; |
_OPT_MODE='text'; |
3968 |
fi; |
fi; |
3996 |
_OPT_DISPLAY="$1"; |
_OPT_DISPLAY="$1"; |
3997 |
shift; |
shift; |
3998 |
;; |
;; |
3999 |
|
--do-nothing) |
4000 |
|
leave; |
4001 |
|
;; |
4002 |
--dvi) |
--dvi) |
4003 |
_OPT_MODE='dvi'; |
_OPT_MODE='dvi'; |
4004 |
;; |
;; |
4103 |
_MAN_FORCE="no"; |
_MAN_FORCE="no"; |
4104 |
_MAN_ENABLE="no"; |
_MAN_ENABLE="no"; |
4105 |
;; |
;; |
4106 |
--pager) # set paging program for tty mode, arg |
--pager|--tty-viewer) # set paging program for tty mode, arg |
4107 |
_OPT_PAGER="$1"; |
_OPT_PAGER="$1"; |
4108 |
shift; |
shift; |
4109 |
;; |
;; |
4189 |
esac; |
esac; |
4190 |
done; |
done; |
4191 |
shift; # remove `--' argument |
shift; # remove `--' argument |
4192 |
|
if obj _DEBUG is_not_yes |
|
if obj _DEBUG is_not_yes; |
|
4193 |
then |
then |
4194 |
if obj _OPT_DEBUG is_yes; |
if obj _OPT_DEBUG is_yes |
4195 |
then |
then |
4196 |
_DEBUG='yes'; |
_DEBUG='yes'; |
4197 |
_DEBUG_LM='yes'; |
_DEBUG_LM='yes'; |
4198 |
_DEBUG_KEEP_FILES='yes'; |
_DEBUG_KEEP_FILES='yes'; |
4199 |
|
_DEBUG_PRINT_PARAMS='yes'; |
4200 |
|
_DEBUG_PRINT_SHELL='yes'; |
4201 |
fi; |
fi; |
4202 |
fi; |
fi; |
4203 |
|
|
4204 |
# Remaining arguments are file names (filespecs). |
# Remaining arguments are file names (filespecs). |
4205 |
# Save them to list $_FILEARGS |
# Save them to list $_FILEARGS |
4206 |
if is_equal "$#" 0; |
if is_equal "$#" 0 |
4207 |
then # use "-" for standard input |
then # use "-" for standard input |
4208 |
set x '-'; |
set x '-'; |
4209 |
shift; |
shift; |
4210 |
fi; |
fi; |
4211 |
_FILEARGS=''; |
_FILEARGS=''; |
4212 |
list_append _FILEARGS "$@"; |
list_append _FILEARGS "$@"; |
4213 |
if list_has _FILEARGS '-'; |
if list_has _FILEARGS '-' |
4214 |
then |
then |
4215 |
save_stdin; |
save_stdin; |
4216 |
fi; |
fi; |
4217 |
# $_FILEARGS must be retrieved with `eval set x "$_FILEARGS"; shift;' |
# $_FILEARGS must be retrieved with `eval set x "$_FILEARGS"; shift;' |
4218 |
eval ${_UNSET} mpa_arg; |
eval ${_UNSET} mpa_arg; |
|
eval ${_UNSET} mpa_code; |
|
4219 |
eval ${_UNSET} mpa_dpi; |
eval ${_UNSET} mpa_dpi; |
4220 |
eval ${_UNSET} mpa_opt; |
eval ${_UNSET} mpa_opt; |
4221 |
eval ${_UNSET} mpa_optchar; |
eval ${_UNSET} mpa_optchar; |
4246 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4247 |
;; |
;; |
4248 |
ascii|cp1047|latin1|utf8) |
ascii|cp1047|latin1|utf8) |
4249 |
if obj _OPT_MODE is_not_equal text; |
if obj _OPT_MODE is_not_equal text |
4250 |
then |
then |
4251 |
_OPT_MODE=tty; # default text mode |
_OPT_MODE=tty; # default text mode |
4252 |
fi; |
fi; |
4265 |
} # _check_device_with_mode() of main_parse_args() |
} # _check_device_with_mode() of main_parse_args() |
4266 |
|
|
4267 |
|
|
|
landmark '16: main_set_mode()'; |
|
4268 |
######################################################################## |
######################################################################## |
4269 |
# main_set_mode () |
# main_set_mode () |
4270 |
# |
# |
4281 |
func_check main_set_mode = 0 "$@"; |
func_check main_set_mode = 0 "$@"; |
4282 |
|
|
4283 |
# handle apropos |
# handle apropos |
4284 |
if obj _OPT_APROPOS is_not_empty; |
if obj _OPT_APROPOS is_not_empty |
4285 |
then |
then |
4286 |
apropos "${_OPT_APROPOS}"; |
apropos "${_OPT_APROPOS}"; |
4287 |
msm_code="$?"; |
leave "$?"; |
|
clean_up; |
|
|
exit "${msm_code}"; |
|
4288 |
fi; |
fi; |
4289 |
if obj _OPT_APROPOS_DATA is_not_empty; |
if obj _OPT_APROPOS_DATA is_not_empty |
4290 |
then |
then |
4291 |
apropos "$@" | grep '^[^(]*([457])'; |
apropos "$@" | grep '^[^(]*([457])'; |
4292 |
msm_code="$?"; |
leave "$?"; |
|
clean_up; |
|
|
exit "${msm_code}"; |
|
4293 |
fi; |
fi; |
4294 |
if obj _OPT_APROPOS_DEVEL is_not_empty; |
if obj _OPT_APROPOS_DEVEL is_not_empty |
4295 |
then |
then |
4296 |
apropos "$@" | grep '^[^(]*([239])'; |
apropos "$@" | grep '^[^(]*([239])'; |
4297 |
msm_code="$?"; |
leave "$?"; |
|
clean_up; |
|
|
exit "${msm_code}"; |
|
4298 |
fi; |
fi; |
4299 |
if obj _OPT_APROPOS_PROGS is_not_empty; |
if obj _OPT_APROPOS_PROGS is_not_empty |
4300 |
then |
then |
4301 |
apropos "$@" | grep '^[^(]*([168])'; |
apropos "$@" | grep '^[^(]*([168])'; |
4302 |
msm_code="$?"; |
leave "$?"; |
|
clean_up; |
|
|
exit "${msm_code}"; |
|
4303 |
fi; |
fi; |
4304 |
|
|
4305 |
# set display |
# set display |
4306 |
if obj _OPT_DISPLAY is_not_empty; |
if obj _OPT_DISPLAY is_not_empty |
4307 |
then |
then |
4308 |
DISPLAY="${_OPT_DISPLAY}"; |
DISPLAY="${_OPT_DISPLAY}"; |
4309 |
fi; |
fi; |
4310 |
|
|
4311 |
if obj _OPT_V is_yes; |
if obj _OPT_V is_yes |
4312 |
then |
then |
4313 |
list_append _ADDOPTS_GROFF '-V'; |
list_append _ADDOPTS_GROFF '-V'; |
4314 |
fi; |
fi; |
4315 |
if obj _OPT_Z is_yes; |
if obj _OPT_Z is_yes |
4316 |
then |
then |
4317 |
_DISPLAY_MODE='groff'; |
_DISPLAY_MODE='groff'; |
4318 |
list_append _ADDOPTS_GROFF '-Z'; |
list_append _ADDOPTS_GROFF '-Z'; |
4319 |
fi; |
fi; |
4320 |
if obj _OPT_MODE is_equal 'groff'; |
if obj _OPT_MODE is_equal 'groff' |
4321 |
then |
then |
4322 |
_DISPLAY_MODE='groff'; |
_DISPLAY_MODE='groff'; |
4323 |
fi; |
fi; |
4324 |
if obj _DISPLAY_MODE is_equal 'groff'; |
if obj _DISPLAY_MODE is_equal 'groff' |
4325 |
then |
then |
|
eval ${_UNSET} msm_code; |
|
4326 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4327 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4328 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4329 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4330 |
fi; |
fi; |
4331 |
|
|
4332 |
if obj _OPT_MODE is_equal 'source'; |
if obj _OPT_MODE is_equal 'source' |
4333 |
then |
then |
4334 |
_DISPLAY_MODE='source'; |
_DISPLAY_MODE='source'; |
|
eval ${_UNSET} msm_code; |
|
4335 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4336 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4337 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4342 |
'') # automatic mode |
'') # automatic mode |
4343 |
case "${_OPT_DEVICE}" in |
case "${_OPT_DEVICE}" in |
4344 |
X*) |
X*) |
4345 |
if obj DISPLAY is_empty; |
if obj DISPLAY is_empty |
4346 |
then |
then |
4347 |
error "main_set_mode(): \ |
error "main_set_mode(): \ |
4348 |
no X display found for device ${_OPT_DEVICE}"; |
no X display found for device ${_OPT_DEVICE}"; |
4349 |
fi; |
fi; |
4350 |
_DISPLAY_MODE='x'; |
_DISPLAY_MODE='x'; |
|
eval ${_UNSET} msm_code; |
|
4351 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4352 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4353 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4354 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4355 |
;; |
;; |
4356 |
ascii|cp1047|latin1|utf8) |
ascii|cp1047|latin1|utf8) |
4357 |
if obj _DISPLAY_MODE is_not_equal 'text'; |
if obj _DISPLAY_MODE is_not_equal 'text' |
4358 |
then |
then |
4359 |
_DISPLAY_MODE='tty'; |
_DISPLAY_MODE='tty'; |
4360 |
fi; |
fi; |
|
eval ${_UNSET} msm_code; |
|
4361 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4362 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4363 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4364 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4365 |
;; |
;; |
4366 |
esac; |
esac; |
4367 |
if obj DISPLAY is_empty; |
if obj DISPLAY is_empty |
4368 |
then |
then |
4369 |
_DISPLAY_MODE='tty'; |
_DISPLAY_MODE='tty'; |
|
eval ${_UNSET} msm_code; |
|
4370 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4371 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4372 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4373 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4374 |
fi; |
fi; |
4375 |
|
|
4376 |
if obj _OPT_DEFAULT_MODES is_empty; |
if obj _OPT_DEFAULT_MODES is_empty |
4377 |
then |
then |
4378 |
msm_modes="${_DEFAULT_MODES}"; |
msm_modes="${_DEFAULT_MODES}"; |
4379 |
else |
else |
4382 |
;; |
;; |
4383 |
text) |
text) |
4384 |
_DISPLAY_MODE='text'; |
_DISPLAY_MODE='text'; |
|
eval ${_UNSET} msm_code; |
|
4385 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4386 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4387 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4389 |
;; |
;; |
4390 |
tty) |
tty) |
4391 |
_DISPLAY_MODE='tty'; |
_DISPLAY_MODE='tty'; |
|
eval ${_UNSET} msm_code; |
|
4392 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4393 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4394 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4395 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4396 |
;; |
;; |
4397 |
*) # display mode was given |
*) # display mode was given |
4398 |
if obj DISPLAY is_empty; |
if obj DISPLAY is_empty |
4399 |
then |
then |
4400 |
error "main_set_mode(): \ |
error "main_set_mode(): \ |
4401 |
you must be in X Window for ${_OPT_MODE} mode."; |
you must be in X Window for ${_OPT_MODE} mode."; |
4407 |
# only viewer modes are left |
# only viewer modes are left |
4408 |
eval set x "$(list_from_split "${msm_modes}" ',')"; |
eval set x "$(list_from_split "${msm_modes}" ',')"; |
4409 |
shift; |
shift; |
4410 |
while test "$#" -gt 0; |
while test "$#" -gt 0 |
4411 |
do |
do |
4412 |
m="$1"; |
m="$1"; |
4413 |
shift; |
shift; |
4414 |
case "$m" in |
case "$m" in |
4415 |
text) |
text) |
4416 |
_DISPLAY_MODE='text'; |
_DISPLAY_MODE='text'; |
|
eval ${_UNSET} msm_code; |
|
4417 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4418 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4419 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4421 |
;; |
;; |
4422 |
tty) |
tty) |
4423 |
_DISPLAY_MODE='tty'; |
_DISPLAY_MODE='tty'; |
|
eval ${_UNSET} msm_code; |
|
4424 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4425 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4426 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4427 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4428 |
;; |
;; |
4429 |
x) |
x) |
4430 |
if obj _OPT_VIEWER_X is_not_empty; |
if obj _OPT_VIEWER_X is_not_empty |
4431 |
then |
then |
4432 |
msm_viewers="${_OPT_VIEWER_X}"; |
msm_viewers="${_OPT_VIEWER_X}"; |
4433 |
else |
else |
4434 |
msm_viewers="${_VIEWER_X}"; |
msm_viewers="${_VIEWER_X}"; |
4435 |
fi; |
fi; |
4436 |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
4437 |
if is_not_equal "$?" 0; |
if is_not_equal "$?" 0 |
4438 |
then |
then |
4439 |
continue; |
continue; |
4440 |
fi; |
fi; |
4441 |
_DISPLAY_PROG="${msm_viewer}"; |
_DISPLAY_PROG="${msm_viewer}"; |
4442 |
_DISPLAY_MODE='x'; |
_DISPLAY_MODE='x'; |
|
eval ${_UNSET} msm_code; |
|
4443 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4444 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4445 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4447 |
;; |
;; |
4448 |
X) |
X) |
4449 |
_DISPLAY_MODE='X'; |
_DISPLAY_MODE='X'; |
|
eval ${_UNSET} msm_code; |
|
4450 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4451 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4452 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4453 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4454 |
;; |
;; |
4455 |
dvi) |
dvi) |
4456 |
if obj _OPT_VIEWER_DVI is_not_empty; |
if obj _OPT_VIEWER_DVI is_not_empty |
4457 |
then |
then |
4458 |
msm_viewers="${_OPT_VIEWER_DVI}"; |
msm_viewers="${_OPT_VIEWER_DVI}"; |
4459 |
else |
else |
4460 |
msm_viewers="${_VIEWER_DVI}"; |
msm_viewers="${_VIEWER_DVI}"; |
4461 |
fi; |
fi; |
4462 |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
4463 |
if is_not_equal "$?" 0; |
if is_not_equal "$?" 0 |
4464 |
then |
then |
4465 |
continue; |
continue; |
4466 |
fi; |
fi; |
4467 |
_DISPLAY_PROG="${msm_viewer}"; |
_DISPLAY_PROG="${msm_viewer}"; |
4468 |
_DISPLAY_MODE="dvi"; |
_DISPLAY_MODE="dvi"; |
|
eval ${_UNSET} msm_code; |
|
4469 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4470 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4471 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4472 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4473 |
;; |
;; |
4474 |
pdf) |
pdf) |
4475 |
if obj _OPT_VIEWER_PDF is_not_empty; |
if obj _OPT_VIEWER_PDF is_not_empty |
4476 |
then |
then |
4477 |
msm_viewers="${_OPT_VIEWER_PDF}"; |
msm_viewers="${_OPT_VIEWER_PDF}"; |
4478 |
else |
else |
4479 |
msm_viewers="${_VIEWER_PDF}"; |
msm_viewers="${_VIEWER_PDF}"; |
4480 |
fi; |
fi; |
4481 |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
4482 |
if is_not_equal "$?" 0; |
if is_not_equal "$?" 0 |
4483 |
then |
then |
4484 |
continue; |
continue; |
4485 |
fi; |
fi; |
4486 |
_DISPLAY_PROG="${msm_viewer}"; |
_DISPLAY_PROG="${msm_viewer}"; |
4487 |
_DISPLAY_MODE="pdf"; |
_DISPLAY_MODE="pdf"; |
|
eval ${_UNSET} msm_code; |
|
4488 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4489 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4490 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4491 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4492 |
;; |
;; |
4493 |
ps) |
ps) |
4494 |
if obj _OPT_VIEWER_PS is_not_empty; |
if obj _OPT_VIEWER_PS is_not_empty |
4495 |
then |
then |
4496 |
msm_viewers="${_OPT_VIEWER_PS}"; |
msm_viewers="${_OPT_VIEWER_PS}"; |
4497 |
else |
else |
4498 |
msm_viewers="${_VIEWER_PS}"; |
msm_viewers="${_VIEWER_PS}"; |
4499 |
fi; |
fi; |
4500 |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
4501 |
if is_not_equal "$?" 0; |
if is_not_equal "$?" 0 |
4502 |
then |
then |
4503 |
continue; |
continue; |
4504 |
fi; |
fi; |
4505 |
_DISPLAY_PROG="${msm_viewer}"; |
_DISPLAY_PROG="${msm_viewer}"; |
4506 |
_DISPLAY_MODE="ps"; |
_DISPLAY_MODE="ps"; |
|
eval ${_UNSET} msm_code; |
|
4507 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4508 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4509 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4510 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4511 |
;; |
;; |
4512 |
html) |
html) |
4513 |
if obj _OPT_VIEWER_HTML is_not_empty; |
if obj _OPT_VIEWER_HTML is_not_empty |
4514 |
then |
then |
4515 |
msm_viewers="${_OPT_VIEWER_HTML}"; |
msm_viewers="${_OPT_VIEWER_HTML}"; |
4516 |
else |
else |
4517 |
msm_viewers="${_VIEWER_HTML}"; |
msm_viewers="${_VIEWER_HTML}"; |
4518 |
fi; |
fi; |
4519 |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
msm_viewer="$(_get_first_prog "${msm_viewers}")"; |
4520 |
if is_not_equal "$?" 0; |
if is_not_equal "$?" 0 |
4521 |
then |
then |
4522 |
continue; |
continue; |
4523 |
fi; |
fi; |
4524 |
_DISPLAY_PROG="${msm_viewer}"; |
_DISPLAY_PROG="${msm_viewer}"; |
4525 |
_DISPLAY_MODE=html; |
_DISPLAY_MODE=html; |
|
eval ${_UNSET} msm_code; |
|
4526 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4527 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4528 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4530 |
;; |
;; |
4531 |
esac; |
esac; |
4532 |
done; |
done; |
|
eval ${_UNSET} msm_code; |
|
4533 |
eval ${_UNSET} msm_modes; |
eval ${_UNSET} msm_modes; |
4534 |
eval ${_UNSET} msm_viewer; |
eval ${_UNSET} msm_viewer; |
4535 |
eval ${_UNSET} msm_viewers; |
eval ${_UNSET} msm_viewers; |
4552 |
# |
# |
4553 |
_get_first_prog() |
_get_first_prog() |
4554 |
{ |
{ |
4555 |
if is_equal "$#" 0; |
if is_equal "$#" 0 |
4556 |
then |
then |
4557 |
error "_get_first_prog() needs 1 argument."; |
error "_get_first_prog() needs 1 argument."; |
4558 |
fi; |
fi; |
4559 |
if is_empty "$1"; |
if is_empty "$1" |
4560 |
then |
then |
4561 |
return "${_BAD}"; |
return "${_BAD}"; |
4562 |
fi; |
fi; |
4565 |
for i |
for i |
4566 |
do |
do |
4567 |
_gfp_i="$i"; |
_gfp_i="$i"; |
4568 |
if obj _gfp_i is_empty; |
if obj _gfp_i is_empty |
4569 |
then |
then |
4570 |
continue; |
continue; |
4571 |
fi; |
fi; |
4572 |
if eval is_prog "$(get_first_essential ${_gfp_i})"; |
if eval is_prog "$(get_first_essential ${_gfp_i})" |
4573 |
then |
then |
4574 |
cat <<EOF |
obj _gfp_i echo1; |
|
${_gfp_i} |
|
|
EOF |
|
4575 |
eval ${_UNSET} _gfp_i; |
eval ${_UNSET} _gfp_i; |
4576 |
return "${_GOOD}"; |
return "${_GOOD}"; |
4577 |
fi; |
fi; |
4581 |
} # _get_first_prog() of main_set_mode() |
} # _get_first_prog() of main_set_mode() |
4582 |
|
|
4583 |
|
|
|
landmark '17: main_do_fileargs()'; |
|
4584 |
####################################################################### |
####################################################################### |
4585 |
# main_do_fileargs () |
# main_do_fileargs () |
4586 |
# |
# |
4599 |
shift; |
shift; |
4600 |
eval ${_UNSET} _FILEARGS; |
eval ${_UNSET} _FILEARGS; |
4601 |
# temporary storage of all input to $_TMP_CAT |
# temporary storage of all input to $_TMP_CAT |
4602 |
while test "$#" -ge 2; |
while test "$#" -ge 2 |
4603 |
do |
do |
4604 |
# test for `s name' arguments, with `s' a 1-char standard section |
# test for `s name' arguments, with `s' a 1-char standard section |
4605 |
mdfa_filespec="$1"; |
mdfa_filespec="$1"; |
4609 |
continue; |
continue; |
4610 |
;; |
;; |
4611 |
'-') |
'-') |
4612 |
if register_file '-'; |
if register_file '-' |
4613 |
then |
then |
4614 |
mdfa_exitcode="${_GOOD}"; |
mdfa_exitcode="${_GOOD}"; |
4615 |
fi; |
fi; |
4616 |
continue; |
continue; |
4617 |
;; |
;; |
4618 |
?) |
?) |
4619 |
if list_has_not _MAN_AUTO_SEC "${mdfa_filespec}"; |
if list_has_not _MAN_AUTO_SEC "${mdfa_filespec}" |
4620 |
then |
then |
4621 |
if do_filearg "${mdfa_filespec}"; |
if do_filearg "${mdfa_filespec}" |
4622 |
then |
then |
4623 |
mdfa_exitcode="${_GOOD}"; |
mdfa_exitcode="${_GOOD}"; |
4624 |
fi; |
fi; |
4627 |
mdfa_name="$1"; |
mdfa_name="$1"; |
4628 |
case "${mdfa_name}" in |
case "${mdfa_name}" in |
4629 |
*/*|man:*|*\(*\)|*."${mdfa_filespec}") |
*/*|man:*|*\(*\)|*."${mdfa_filespec}") |
4630 |
if do_filearg "${mdfa_filespec}"; |
if do_filearg "${mdfa_filespec}" |
4631 |
then |
then |
4632 |
mdfa_exitcode="${_GOOD}"; |
mdfa_exitcode="${_GOOD}"; |
4633 |
fi; |
fi; |
4634 |
continue; |
continue; |
4635 |
;; |
;; |
4636 |
esac; |
esac; |
4637 |
if do_filearg "man:${mdfa_name}(${mdfa_filespec})"; |
if do_filearg "man:${mdfa_name}(${mdfa_filespec})" |
4638 |
then |
then |
4639 |
mdfa_exitcode="${_GOOD}"; |
mdfa_exitcode="${_GOOD}"; |
4640 |
shift; |
shift; |
4641 |
continue; |
continue; |
4642 |
else |
else |
4643 |
if do_filearg "${mdfa_filespec}"; |
if do_filearg "${mdfa_filespec}" |
4644 |
then |
then |
4645 |
mdfa_exitcode="${_GOOD}"; |
mdfa_exitcode="${_GOOD}"; |
4646 |
fi; |
fi; |
4648 |
fi; |
fi; |
4649 |
;; |
;; |
4650 |
*) |
*) |
4651 |
if do_filearg "${mdfa_filespec}"; |
if do_filearg "${mdfa_filespec}" |
4652 |
then |
then |
4653 |
mdfa_exitcode="${_GOOD}"; |
mdfa_exitcode="${_GOOD}"; |
4654 |
fi; |
fi; |
4656 |
;; |
;; |
4657 |
esac; |
esac; |
4658 |
done; # end of `s name' test |
done; # end of `s name' test |
4659 |
while test "$#" -gt 0; |
while test "$#" -gt 0 |
4660 |
do |
do |
4661 |
mdfa_filespec="$1"; |
mdfa_filespec="$1"; |
4662 |
shift; |
shift; |
4663 |
if do_filearg "${mdfa_filespec}"; |
if do_filearg "${mdfa_filespec}" |
4664 |
then |
then |
4665 |
mdfa_exitcode="${_GOOD}"; |
mdfa_exitcode="${_GOOD}"; |
4666 |
fi; |
fi; |
4667 |
done; |
done; |
4668 |
if obj _DEBUG_KEEP_FILES is_not_yes; |
obj _TMP_STDIN rm_file_with_debug; |
4669 |
then |
if is_equal "${mdfa_exitcode}" "${_BAD}" |
|
rm -f "${_TMP_STDIN}"; |
|
|
fi; |
|
|
if is_equal "${mdfa_exitcode}" "${_BAD}"; |
|
4670 |
then |
then |
4671 |
eval ${_UNSET} mdfa_exitcode; |
eval ${_UNSET} mdfa_exitcode; |
4672 |
eval ${_UNSET} mdfa_filespec; |
eval ${_UNSET} mdfa_filespec; |
4680 |
} # main_do_fileargs() |
} # main_do_fileargs() |
4681 |
|
|
4682 |
|
|
|
landmark '18: main_set_resources()'; |
|
4683 |
######################################################################## |
######################################################################## |
4684 |
# main_set_resources () |
# main_set_resources () |
4685 |
# |
# |
4699 |
_OUTPUT_FILE_NAME=''; |
_OUTPUT_FILE_NAME=''; |
4700 |
eval set x "${msr_title}"; |
eval set x "${msr_title}"; |
4701 |
shift; |
shift; |
4702 |
until is_equal "$#" 0; |
until is_equal "$#" 0 |
4703 |
do |
do |
4704 |
msr_n="$1"; |
msr_n="$1"; |
4705 |
case "${msr_n}" in |
case "${msr_n}" in |
4707 |
continue; |
continue; |
4708 |
;; |
;; |
4709 |
,*) |
,*) |
4710 |
msr_n="$(echo x"$1" | sed -e 's/^x,,*//')"; |
msr_n="$(echo1 "$1" | sed -e 's/^,,*//')"; |
4711 |
;; |
;; |
4712 |
esac |
esac |
4713 |
if obj msr_n is_empty; |
if obj msr_n is_empty |
4714 |
then |
then |
4715 |
continue; |
continue; |
4716 |
fi; |
fi; |
4717 |
if obj _OUTPUT_FILE_NAME is_not_empty; |
if obj _OUTPUT_FILE_NAME is_not_empty |
4718 |
then |
then |
4719 |
_OUTPUT_FILE_NAME="${_OUTPUT_FILE_NAME}"','; |
_OUTPUT_FILE_NAME="${_OUTPUT_FILE_NAME}"','; |
4720 |
fi; |
fi; |
4731 |
esac; |
esac; |
4732 |
_OUTPUT_FILE_NAME="${_TMP_DIR}/${_OUTPUT_FILE_NAME}"; |
_OUTPUT_FILE_NAME="${_TMP_DIR}/${_OUTPUT_FILE_NAME}"; |
4733 |
|
|
4734 |
if obj _DISPLAY_PROG is_empty; |
if obj _DISPLAY_PROG is_empty |
4735 |
then # for example, for groff mode |
then # for example, for groff mode |
4736 |
_DISPLAY_ARGS=''; |
_DISPLAY_ARGS=''; |
4737 |
eval ${_UNSET} msr_n; |
eval ${_UNSET} msr_n; |
4744 |
eval set x "${_DISPLAY_PROG}"; |
eval set x "${_DISPLAY_PROG}"; |
4745 |
shift; |
shift; |
4746 |
msr_prog="$(base_name "$1")"; |
msr_prog="$(base_name "$1")"; |
4747 |
|
shift; |
4748 |
|
if test $# != 0 |
4749 |
|
then |
4750 |
|
if obj _DISPLAY_PROG is_empty |
4751 |
|
then |
4752 |
|
_DISPLAY_ARGS="$*"; |
4753 |
|
else |
4754 |
|
_DISPLAY_ARGS="$* ${_DISPLAY_ARGS}"; |
4755 |
|
fi; |
4756 |
|
fi; |
4757 |
msr_rl=''; |
msr_rl=''; |
4758 |
if obj _OPT_BD is_not_empty; |
if obj _OPT_BD is_not_empty |
4759 |
then |
then |
4760 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4761 |
ghostview|gv|gxditview|xditview|xdvi) |
ghostview|gv|gxditview|xditview|xdvi) |
4762 |
list_append msr_rl '-bd' "${_OPT_BD}"; |
list_append msr_rl '-bd' "${_OPT_BD}"; |
4763 |
;; |
;; |
4764 |
esac; |
esac; |
4765 |
fi; |
fi; |
4766 |
if obj _OPT_BG is_not_empty; |
if obj _OPT_BG is_not_empty |
4767 |
then |
then |
4768 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4769 |
ghostview|gv|gxditview|xditview|xdvi) |
ghostview|gv|gxditview|xditview|xdvi) |
4770 |
list_append msr_rl '-bg' "${_OPT_BG}"; |
list_append msr_rl '-bg' "${_OPT_BG}"; |
4771 |
;; |
;; |
4772 |
xpdf) |
kghostview) |
4773 |
list_append msr_rl '-papercolor' "${_OPT_BG}"; |
list_append msr_rl '--bg' "${_OPT_BG}"; |
4774 |
;; |
;; |
4775 |
|
xpdf) |
4776 |
|
list_append msr_rl '-papercolor' "${_OPT_BG}"; |
4777 |
|
;; |
4778 |
esac; |
esac; |
4779 |
fi; |
fi; |
4780 |
if obj _OPT_BW is_not_empty; |
if obj _OPT_BW is_not_empty |
4781 |
then |
then |
4782 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4783 |
ghostview|gv|gxditview|xditview|xdvi) |
ghostview|gv|gxditview|xditview|xdvi) |
4784 |
_list_append msr_rl '-bw' "${_OPT_BW}"; |
_list_append msr_rl '-bw' "${_OPT_BW}"; |
4785 |
;; |
;; |
4786 |
esac; |
esac; |
4787 |
fi; |
fi; |
4788 |
if obj _OPT_FG is_not_empty; |
if obj _OPT_FG is_not_empty |
4789 |
then |
then |
4790 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4791 |
ghostview|gv|gxditview|xditview|xdvi) |
ghostview|gv|gxditview|xditview|xdvi) |
4792 |
list_append msr_rl '-fg' "${_OPT_FG}"; |
list_append msr_rl '-fg' "${_OPT_FG}"; |
4793 |
;; |
;; |
4794 |
|
kghostview) |
4795 |
|
list_append msr_rl '--fg' "${_OPT_FG}"; |
4796 |
|
;; |
4797 |
esac; |
esac; |
4798 |
fi; |
fi; |
4799 |
if is_not_empty "${_OPT_FN}"; |
if is_not_empty "${_OPT_FN}" |
4800 |
then |
then |
4801 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4802 |
ghostview|gv|gxditview|xditview|xdvi) |
ghostview|gv|gxditview|xditview|xdvi) |
4803 |
list_append msr_rl '-fn' "${_OPT_FN}"; |
list_append msr_rl '-fn' "${_OPT_FN}"; |
4804 |
;; |
;; |
4805 |
|
kghostview) |
4806 |
|
list_append msr_rl '--fn' "${_OPT_FN}"; |
4807 |
|
;; |
4808 |
esac; |
esac; |
4809 |
fi; |
fi; |
4810 |
if is_not_empty "${_OPT_GEOMETRY}"; |
if is_not_empty "${_OPT_GEOMETRY}" |
4811 |
then |
then |
4812 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4813 |
ghostview|gv|gxditview|xditview|xdvi|xpdf) |
ghostview|gv|gxditview|xditview|xdvi|xpdf) |
4814 |
list_append msr_rl '-geometry' "${_OPT_GEOMETRY}"; |
list_append msr_rl '-geometry' "${_OPT_GEOMETRY}"; |
4815 |
;; |
;; |
4816 |
|
kghostview) |
4817 |
|
list_append msr_rl '--geometry' "${_OPT_GEOMETRY}"; |
4818 |
|
;; |
4819 |
esac; |
esac; |
4820 |
fi; |
fi; |
4821 |
if is_empty "${_OPT_RESOLUTION}"; |
if is_empty "${_OPT_RESOLUTION}" |
4822 |
then |
then |
4823 |
_OPT_RESOLUTION="${_DEFAULT_RESOLUTION}"; |
_OPT_RESOLUTION="${_DEFAULT_RESOLUTION}"; |
4824 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4825 |
gxditview|xditview) |
gxditview|xditview) |
4826 |
list_append msr_rl '-resolution' "${_DEFAULT_RESOLUTION}"; |
list_append msr_rl '-resolution' "${_DEFAULT_RESOLUTION}"; |
4827 |
|
;; |
4828 |
|
xpdf) |
4829 |
|
case "${_DEFAULT_RESOLUTION}" in |
4830 |
|
75) |
4831 |
|
# 72dpi is '100' |
4832 |
|
list_append msr_rl '-z' '104'; |
4833 |
;; |
;; |
4834 |
xpdf) |
100) |
4835 |
case "${_DEFAULT_RESOLUTION}" in |
list_append msr_rl '-z' '139'; |
|
75) |
|
|
# 72dpi is '100' |
|
|
list_append msr_rl '-z' '104'; |
|
|
;; |
|
|
100) |
|
|
list_append msr_rl '-z' '139'; |
|
|
;; |
|
|
esac; |
|
4836 |
;; |
;; |
4837 |
|
esac; |
4838 |
|
;; |
4839 |
esac; |
esac; |
4840 |
else |
else |
4841 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4842 |
ghostview|gv|gxditview|xditview|xdvi) |
ghostview|gv|gxditview|xditview|xdvi) |
4843 |
list_append msr_rl '-resolution' "${_OPT_RESOLUTION}"; |
list_append msr_rl '-resolution' "${_OPT_RESOLUTION}"; |
4844 |
|
;; |
4845 |
|
xpdf) |
4846 |
|
case "${_OPT_RESOLUTION}" in |
4847 |
|
75) |
4848 |
|
list_append msr_rl '-z' '104'; |
4849 |
|
# '100' corresponds to 72dpi |
4850 |
;; |
;; |
4851 |
xpdf) |
100) |
4852 |
case "${_OPT_RESOLUTION}" in |
list_append msr_rl '-z' '139'; |
|
75) |
|
|
list_append msr_rl '-z' '104'; |
|
|
# '100' corresponds to 72dpi |
|
|
;; |
|
|
100) |
|
|
list_append msr_rl '-z' '139'; |
|
|
;; |
|
|
esac; |
|
4853 |
;; |
;; |
4854 |
|
esac; |
4855 |
|
;; |
4856 |
esac; |
esac; |
4857 |
fi; |
fi; |
4858 |
if is_yes "${_OPT_ICONIC}"; |
if is_yes "${_OPT_ICONIC}" |
4859 |
then |
then |
4860 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4861 |
ghostview|gv|gxditview|xditview|xdvi) |
ghostview|gv|gxditview|xditview|xdvi) |
4862 |
list_append msr_rl '-iconic'; |
list_append msr_rl '-iconic'; |
4863 |
;; |
;; |
4864 |
esac; |
esac; |
4865 |
fi; |
fi; |
4866 |
if is_yes "${_OPT_RV}"; |
if is_yes "${_OPT_RV}" |
4867 |
then |
then |
4868 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4869 |
ghostview|gv|gxditview|xditview|xdvi) |
ghostview|gv|gxditview|xditview|xdvi) |
4870 |
list_append msr_rl '-rv'; |
list_append msr_rl '-rv'; |
4871 |
;; |
;; |
4872 |
esac; |
esac; |
4873 |
fi; |
fi; |
4874 |
if is_not_empty "${_OPT_XRM}"; |
if is_not_empty "${_OPT_XRM}" |
4875 |
then |
then |
4876 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4877 |
ghostview|gv|gxditview|xditview|xdvi|xpdf) |
ghostview|gv|gxditview|xditview|xdvi|xpdf) |
4878 |
eval set x "${_OPT_XRM}"; |
eval set x "${_OPT_XRM}"; |
4879 |
shift; |
shift; |
4880 |
for i |
for i |
4881 |
do |
do |
4882 |
list_append msr_rl '-xrm' "$i"; |
list_append msr_rl '-xrm' "$i"; |
4883 |
done; |
done; |
4884 |
;; |
;; |
4885 |
esac; |
esac; |
4886 |
fi; |
fi; |
4887 |
if is_not_empty "${msr_title}"; |
if is_not_empty "${msr_title}" |
4888 |
then |
then |
4889 |
case "${msr_prog}" in |
case "${msr_prog}" in |
4890 |
gxditview|xditview) |
gxditview|xditview) |
4891 |
list_append msr_rl '-title' "${msr_title}"; |
list_append msr_rl '-title' "${msr_title}"; |
4892 |
;; |
;; |
4893 |
esac; |
esac; |
4894 |
fi; |
fi; |
4895 |
_DISPLAY_ARGS="${msr_rl}"; |
_DISPLAY_ARGS="${msr_rl}"; |
4901 |
} # main_set_resources |
} # main_set_resources |
4902 |
|
|
4903 |
|
|
|
landmark '19: main_display()'; |
|
4904 |
######################################################################## |
######################################################################## |
4905 |
# main_display () |
# main_display () |
4906 |
# |
# |
4923 |
export md_groggy; |
export md_groggy; |
4924 |
export md_modefile; |
export md_modefile; |
4925 |
|
|
4926 |
if obj _TMP_CAT is_non_empty_file; |
if obj _TMP_CAT is_non_empty_file |
4927 |
then |
then |
4928 |
md_modefile="${_OUTPUT_FILE_NAME}"; |
md_modefile="${_OUTPUT_FILE_NAME}"; |
4929 |
else |
else |
|
clean_up; |
|
4930 |
echo2 'groffer: empty input.'; |
echo2 'groffer: empty input.'; |
4931 |
|
clean_up; |
4932 |
eval ${_UNSET} md_modefile; |
eval ${_UNSET} md_modefile; |
4933 |
eval "${return_ok}"; |
eval "${return_ok}"; |
4934 |
fi; |
fi; |
4935 |
|
|
4936 |
|
# go to the temporary directory to be able to access internal data files |
4937 |
|
cd "${_TMP_DIR}" >"${_NULL_DEV}" 2>&1; |
4938 |
|
|
4939 |
case "${_DISPLAY_MODE}" in |
case "${_DISPLAY_MODE}" in |
4940 |
groff) |
groff) |
4941 |
_ADDOPTS_GROFF="${_ADDOPTS_GROFF} ${_ADDOPTS_POST}"; |
_ADDOPTS_GROFF="${_ADDOPTS_GROFF} ${_ADDOPTS_POST}"; |
4942 |
if obj _OPT_DEVICE is_not_empty; |
if obj _OPT_DEVICE is_not_empty |
4943 |
then |
then |
4944 |
_ADDOPTS_GROFF="${_ADDOPTS_GROFF} -T${_OPT_DEVICE}"; |
_ADDOPTS_GROFF="${_ADDOPTS_GROFF} -T${_OPT_DEVICE}"; |
4945 |
fi; |
fi; |
4946 |
md_groggy="$(tmp_cat | eval grog "${md_options}")"; |
md_groggy="$(tmp_cat | eval grog "${md_options}")"; |
4947 |
trap_clean; |
trap_clean; |
4948 |
if obj _OPT_V is_yes; |
_do_opt_V; |
4949 |
then |
|
4950 |
echo "File: ${md_modefile}"; |
obj md_modefile rm_file; |
4951 |
echo "Mode: ${_DISPLAY_MODE}"; |
mv "${_TMP_CAT}" "${md_modefile}"; |
4952 |
echo "Display program: ${_DISPLAY_PROG} ${_DISPLAY_ARGS}"; |
cat "${md_modefile}" | \ |
4953 |
|
{ |
4954 |
|
trap clean_up 0 2>${_NULL_DEV} || :; |
4955 |
eval "${md_groggy}" "${_ADDOPTS_GROFF}"; |
eval "${md_groggy}" "${_ADDOPTS_GROFF}"; |
4956 |
clean_up; |
clean_up; |
4957 |
else |
} & |
|
# start a new shell program to get another process ID. |
|
|
/bin/sh -c ' |
|
|
set -e; |
|
|
test -f "${md_modefile}" && rm -f "${md_modefile}"; |
|
|
mv "${_TMP_CAT}" "${md_modefile}"; |
|
|
cat "${md_modefile}" | \ |
|
|
( |
|
|
clean_up() |
|
|
{ |
|
|
if test -d "${_TMP_DIR}"; |
|
|
then |
|
|
rm -f -r "'${_TMP_DIR}'" >${_NULL_DEV} 2>&1 || :; |
|
|
fi; |
|
|
} |
|
|
trap clean_up 0 2>${_NULL_DEV} || :; |
|
|
eval "${md_groggy}" "${_ADDOPTS_GROFF}"; |
|
|
) &' |
|
|
fi; |
|
4958 |
;; |
;; |
4959 |
text|tty) |
text|tty) |
4960 |
case "${_OPT_DEVICE}" in |
case "${_OPT_DEVICE}" in |
4972 |
esac; |
esac; |
4973 |
md_addopts="${_ADDOPTS_GROFF} ${_ADDOPTS_POST}"; |
md_addopts="${_ADDOPTS_GROFF} ${_ADDOPTS_POST}"; |
4974 |
md_groggy="$(tmp_cat | grog -T${md_device})"; |
md_groggy="$(tmp_cat | grog -T${md_device})"; |
4975 |
if obj _DISPLAY_MODE is_equal 'text'; |
if obj _DISPLAY_MODE is_equal 'text' |
4976 |
then |
then |
4977 |
if obj _OPT_V is_yes; |
_do_opt_V; |
4978 |
then |
tmp_cat | eval "${md_groggy}" "${md_addopts}"; |
|
echo "File: ${md_modefile}"; |
|
|
echo "Mode: ${_DISPLAY_MODE}"; |
|
|
echo "Display program: ${_DISPLAY_PROG} ${_DISPLAY_ARGS}"; |
|
|
eval "${md_groggy}" "${md_addopts}"; |
|
|
else |
|
|
tmp_cat | eval "${md_groggy}" "${md_addopts}"; |
|
|
fi; |
|
4979 |
else |
else |
4980 |
md_pager=''; |
md_pager=''; |
4981 |
for p in "${_OPT_PAGER}" "${PAGER}" "${_MANOPT_PAGER}" \ |
for p in "${_OPT_PAGER}" "${PAGER}" "${_MANOPT_PAGER}" \ |
4982 |
'less -r -R' 'more' 'pager' 'cat' |
'less -r -R' 'more' 'pager' 'cat' |
4983 |
do |
do |
4984 |
md_p="$p"; |
md_p="$p"; |
4985 |
if eval is_prog ${md_p}; |
if eval is_prog ${md_p} |
4986 |
then # no "" for is_prog() allows args for $p |
then # no "" for is_prog() allows args for $p |
4987 |
md_pager="${md_p}"; |
md_pager="${md_p}"; |
4988 |
break; |
break; |
4989 |
fi; |
fi; |
4990 |
done; |
done; |
4991 |
if obj md_pager is_empty; |
if obj md_pager is_empty |
4992 |
then |
then |
4993 |
error 'main_display(): no pager program found for tty mode'; |
error 'main_display(): no pager program found for tty mode'; |
4994 |
fi; |
fi; |
4995 |
if obj _OPT_V is_yes; |
_do_opt_V; |
4996 |
then |
tmp_cat | eval "${md_groggy}" "${md_addopts}" | \ |
4997 |
echo "File: ${md_modefile}"; |
eval "${md_pager}"; |
|
echo "Mode: ${_DISPLAY_MODE}"; |
|
|
echo "Display program: ${md_pager}"; |
|
|
eval "${md_groggy}" "${md_addopts}"; |
|
|
else |
|
|
tmp_cat | eval "${md_groggy}" "${md_addopts}" | \ |
|
|
eval "${md_pager}"; |
|
|
fi; |
|
4998 |
fi; |
fi; |
4999 |
clean_up; |
clean_up; |
5000 |
;; |
;; |
5040 |
;; |
;; |
5041 |
esac; |
esac; |
5042 |
md_groggy="$(tmp_cat | grog -Tps)"; |
md_groggy="$(tmp_cat | grog -Tps)"; |
5043 |
trap_clean; |
_do_display _make_pdf; |
|
if obj _OPT_V is_yes; |
|
|
then |
|
|
echo "File: ${md_modefile}.pdf"; |
|
|
echo "Mode: ${_DISPLAY_MODE}"; |
|
|
echo "Display program: ${_DISPLAY_PROG} ${_DISPLAY_ARGS}"; |
|
|
eval "${md_groggy}" "${_ADDOPTS_GROFF}"; |
|
|
clean_up; |
|
|
else |
|
|
# start a new shell program to get another process ID. |
|
|
/bin/sh -c ' |
|
|
set -e; |
|
|
_psfile="${md_modefile}.ps"; |
|
|
md_modefile="${md_modefile}.pdf"; |
|
|
test -f "${_psfile}" && rm -f "${_psfile}"; |
|
|
test -f "${md_modefile}" && rm -f "${md_modefile}"; |
|
|
cat "${_TMP_CAT}" | \ |
|
|
eval "${md_groggy}" "${_ADDOPTS_GROFF}" > "${_psfile}"; |
|
|
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \ |
|
|
-sOutputFile="${md_modefile}" -c save pop -f "${_psfile}"; |
|
|
if test _"${_DEBUG_KEEP_FILES}"_ != _yes_; |
|
|
then |
|
|
test -f "${_psfile}" && rm -f "${_psfile}"; |
|
|
test -f "${_TMP_CAT}" && rm -f "${_TMP_CAT}"; |
|
|
fi; |
|
|
( |
|
|
clean_up() { |
|
|
if test -d "${_TMP_DIR}"; |
|
|
then |
|
|
rm -f -r "'${_TMP_DIR}'" >${_NULL_DEV} 2>&1 || :; |
|
|
fi; |
|
|
} |
|
|
trap clean_up 0 2>${_NULL_DEV} || :; |
|
|
eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "${md_modefile}"; |
|
|
) &' |
|
|
fi; |
|
5044 |
;; |
;; |
5045 |
ps) |
ps) |
5046 |
case "${_OPT_DEVICE}" in |
case "${_OPT_DEVICE}" in |
5115 |
} # main_display() |
} # main_display() |
5116 |
|
|
5117 |
|
|
5118 |
# $md_modefile and $md_groggy come from main_display() |
######################## |
5119 |
|
# _do_display ([<prog>]) |
5120 |
|
# |
5121 |
|
# Perform the generation of the output and view the result. If an |
5122 |
|
# argument is given interpret it as a function name that is called in |
5123 |
|
# the midst. |
5124 |
|
# |
5125 |
|
# Globals: $md_modefile, $md_groggy (from main_display()) |
5126 |
|
# |
5127 |
_do_display() |
_do_display() |
5128 |
{ |
{ |
5129 |
func_check _do_display = 0 "$@"; |
func_check _do_display '>=' 0 "$@"; |
5130 |
trap_clean; |
trap_clean; |
5131 |
if obj _OPT_V is_yes; |
_do_opt_V; |
5132 |
|
obj md_modefile rm_file; |
5133 |
|
if cat "${_TMP_CAT}" | \ |
5134 |
|
eval "${md_groggy}" "${_ADDOPTS_GROFF}" > "${md_modefile}" |
5135 |
then |
then |
5136 |
echo "File: ${md_modefile}"; |
:; |
|
echo "Mode: ${_DISPLAY_MODE}"; |
|
|
echo "Display program: ${_DISPLAY_PROG} ${_DISPLAY_ARGS}"; |
|
|
eval "${md_groggy}" "${_ADDOPTS_GROFF}"; |
|
|
clean_up; |
|
5137 |
else |
else |
5138 |
# start a new shell program for another process ID and better |
error "_do_display: error on groff call"; |
5139 |
# cleaning-up of the temporary files. |
fi; |
5140 |
/bin/sh -c ' |
if is_not_empty "$1" |
5141 |
set -e; |
then |
5142 |
test -f "${md_modefile}" && rm -f "${md_modefile}"; |
eval "$1"; |
|
cat "${_TMP_CAT}" | \ |
|
|
eval "${md_groggy}" "${_ADDOPTS_GROFF}" > "${md_modefile}"; |
|
|
if test _"${_DEBUG_KEEP_FILES}"_ != _yes_; |
|
|
then |
|
|
rm -f "${_TMP_CAT}"; |
|
|
fi; |
|
|
( |
|
|
clean_up() { |
|
|
if test -d "${_TMP_DIR}"; |
|
|
then |
|
|
rm -f -r "'${_TMP_DIR}'" >${_NULL_DEV} 2>&1 || :; |
|
|
fi; |
|
|
} |
|
|
trap clean_up 0 2>${_NULL_DEV} || :; |
|
|
eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "${md_modefile}"; |
|
|
) &' |
|
5143 |
fi; |
fi; |
5144 |
|
obj _TMP_CAT rm_file_with_debug; |
5145 |
|
{ |
5146 |
|
trap clean_up 0 2>${_NULL_DEV} || :; |
5147 |
|
eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "\"${md_modefile}\""; |
5148 |
|
clean_up; |
5149 |
|
} & |
5150 |
eval "${return_ok}"; |
eval "${return_ok}"; |
5151 |
} # _do_display() of main_display() |
} # _do_display() of main_display() |
5152 |
|
|
5153 |
|
|
5154 |
|
############# |
5155 |
|
# _do_opt_V () |
5156 |
|
# |
5157 |
|
# Check on option `-V'; if set print the corresponding output and leave. |
5158 |
|
# |
5159 |
|
# Globals: $_ALL_PARAMS, $_ADDOPTS_GROFF, $_DISPLAY_MODE, $_DISPLAY_PROG, |
5160 |
|
# $_DISPLAY_ARGS, $md_groggy, $md_modefile |
5161 |
|
# |
5162 |
|
# Variable prefix: _doV |
5163 |
|
# |
5164 |
|
_do_opt_V() |
5165 |
|
{ |
5166 |
|
func_check _do_opt_V '=' 0 "$@"; |
5167 |
|
if obj _OPT_V is_yes |
5168 |
|
then |
5169 |
|
_OPT_V='no'; |
5170 |
|
echo "Output file: ${md_modefile}"; |
5171 |
|
echo "Display mode: ${_DISPLAY_MODE}"; |
5172 |
|
echo "Display prog: ${_DISPLAY_PROG} ${_DISPLAY_ARGS}"; |
5173 |
|
echo "Parameters: ${_ALL_PARAMS}"; |
5174 |
|
echo "Output of grog: ${md_groggy} $(eval echo1 "'${_ADDOPTS_GROFF}'")"; |
5175 |
|
_doV_res="$(eval "${md_groggy}" "${_ADDOPTS_GROFF}")"; |
5176 |
|
echo "groff -V: ${_doV_res}" |
5177 |
|
leave; |
5178 |
|
fi; |
5179 |
|
eval "${return_ok}"; |
5180 |
|
} # _do_opt_V() of main_display() |
5181 |
|
|
5182 |
|
|
5183 |
|
############## |
5184 |
|
# _make_pdf () |
5185 |
|
# |
5186 |
|
# Transform to pdf format; for pdf mode in _do_display(). |
5187 |
|
# |
5188 |
|
# Globals: $md_modefile (from main_display()) |
5189 |
|
# |
5190 |
|
# Variable prefix: _mp |
5191 |
|
# |
5192 |
|
_make_pdf() |
5193 |
|
{ |
5194 |
|
func_check _do_display '=' 0 "$@"; |
5195 |
|
_mp_psfile="${md_modefile}"; |
5196 |
|
md_modefile="${md_modefile}.pdf"; |
5197 |
|
obj md_modefile rm_file; |
5198 |
|
if gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \ |
5199 |
|
-sOutputFile="${md_modefile}" -c save pop -f "${_mp_psfile}" |
5200 |
|
then |
5201 |
|
:; |
5202 |
|
else |
5203 |
|
error '_make_pdf: could not transform into pdf format.'; |
5204 |
|
fi; |
5205 |
|
obj _mp_psfile rm_file_with_debug; |
5206 |
|
eval ${_UNSET} _mp_psfile; |
5207 |
|
eval "${return_ok}"; |
5208 |
|
} # _make_pdf() of main_display() |
5209 |
|
|
5210 |
|
|
5211 |
######################################################################## |
######################################################################## |
5212 |
# main (<command_line_args>*) |
# main (<command_line_args>*) |
5213 |
# |
# |
5219 |
{ |
{ |
5220 |
func_check main '>=' 0 "$@"; |
func_check main '>=' 0 "$@"; |
5221 |
# Do not change the sequence of the following functions! |
# Do not change the sequence of the following functions! |
5222 |
|
landmark '13: main_init()'; |
5223 |
main_init; |
main_init; |
5224 |
|
landmark '14: main_parse_MANOPT()'; |
5225 |
main_parse_MANOPT; |
main_parse_MANOPT; |
5226 |
|
landmark '15: main_parse_args()'; |
5227 |
main_parse_args "$@"; |
main_parse_args "$@"; |
5228 |
|
landmark '16: main_set_mode()'; |
5229 |
main_set_mode; |
main_set_mode; |
5230 |
|
landmark '17: main_do_fileargs()'; |
5231 |
main_do_fileargs; |
main_do_fileargs; |
5232 |
|
landmark '18: main_set_resources()'; |
5233 |
main_set_resources; |
main_set_resources; |
5234 |
|
landmark '19: main_display()'; |
5235 |
main_display; |
main_display; |
5236 |
eval "${return_ok}"; |
eval "${return_ok}"; |
5237 |
} |
} |