"Fossies" - the Fresh Open Source Software Archive

Member "workman.sh" (11 Aug 2022, 854 Bytes) of package /linux/misc/tzcode2022g.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "workman.sh": 2021e_vs_2022e.

    1 #! /bin/sh
    2 # Convert manual page troff stdin to formatted .txt stdout.
    3 
    4 # This file is in the public domain, so clarified as of
    5 # 2009-05-17 by Arthur David Olson.
    6 
    7 if (type nroff && type perl) >/dev/null 2>&1; then
    8 
    9   # Tell groff not to emit SGR escape sequences (ANSI color escapes).
   10   GROFF_NO_SGR=1
   11   export GROFF_NO_SGR
   12 
   13   echo ".am TH
   14 .hy 0
   15 .na
   16 ..
   17 .rm }H
   18 .rm }F" | nroff -man - ${1+"$@"} | perl -ne '
   19     binmode STDIN, '\'':encoding(utf8)'\'';
   20     binmode STDOUT, '\'':encoding(utf8)'\'';
   21     chomp;
   22     s/.\010//g;
   23     s/\s*$//;
   24     if (/^$/) {
   25         $sawblank = 1;
   26         next;
   27     } else {
   28         if ($sawblank && $didprint) {
   29             print "\n";
   30             $sawblank = 0;
   31         }
   32         print "$_\n";
   33         $didprint = 1;
   34     }
   35   '
   36 elif (type mandoc && type col) >/dev/null 2>&1; then
   37   mandoc -man -T ascii "$@" | col -bx
   38 else
   39   echo >&2 "$0: please install nroff and perl, or mandoc and col"
   40   exit 1
   41 fi