xref: /aosp_15_r20/external/mksh/src/FAQ2HTML.sh (revision 7c356e860f31eadd15fd599fcfdb9fd21f16a9d4)
1*7c356e86SAndroid Build Coastguard Worker#!/bin/sh
2*7c356e86SAndroid Build Coastguard Workerrcsid='$MirOS: src/bin/mksh/FAQ2HTML.sh,v 1.2 2020/10/31 04:17:36 tg Exp $'
3*7c356e86SAndroid Build Coastguard Worker#-
4*7c356e86SAndroid Build Coastguard Worker# Copyright © 2020
5*7c356e86SAndroid Build Coastguard Worker#	mirabilos <[email protected]>
6*7c356e86SAndroid Build Coastguard Worker#
7*7c356e86SAndroid Build Coastguard Worker# Provided that these terms and disclaimer and all copyright notices
8*7c356e86SAndroid Build Coastguard Worker# are retained or reproduced in an accompanying document, permission
9*7c356e86SAndroid Build Coastguard Worker# is granted to deal in this work without restriction, including un‐
10*7c356e86SAndroid Build Coastguard Worker# limited rights to use, publicly perform, distribute, sell, modify,
11*7c356e86SAndroid Build Coastguard Worker# merge, give away, or sublicence.
12*7c356e86SAndroid Build Coastguard Worker#
13*7c356e86SAndroid Build Coastguard Worker# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
14*7c356e86SAndroid Build Coastguard Worker# the utmost extent permitted by applicable law, neither express nor
15*7c356e86SAndroid Build Coastguard Worker# implied; without malicious intent or gross negligence. In no event
16*7c356e86SAndroid Build Coastguard Worker# may a licensor, author or contributor be held liable for indirect,
17*7c356e86SAndroid Build Coastguard Worker# direct, other damage, loss, or other issues arising in any way out
18*7c356e86SAndroid Build Coastguard Worker# of dealing in the work, even if advised of the possibility of such
19*7c356e86SAndroid Build Coastguard Worker# damage or existence of a defect, except proven that it results out
20*7c356e86SAndroid Build Coastguard Worker# of said person’s immediate fault when using the work as intended.
21*7c356e86SAndroid Build Coastguard Worker#-
22*7c356e86SAndroid Build Coastguard Worker
23*7c356e86SAndroid Build Coastguard Workerset -e
24*7c356e86SAndroid Build Coastguard WorkerLC_ALL=C; LANGUAGE=C
25*7c356e86SAndroid Build Coastguard Workerexport LC_ALL; unset LANGUAGE
26*7c356e86SAndroid Build Coastguard Workernl='
27*7c356e86SAndroid Build Coastguard Worker'
28*7c356e86SAndroid Build Coastguard Workersrcdir=$(dirname "$0")
29*7c356e86SAndroid Build Coastguard Worker
30*7c356e86SAndroid Build Coastguard Workerp=--posix
31*7c356e86SAndroid Build Coastguard Workersed $p -e q </dev/null >/dev/null 2>&1 || p=
32*7c356e86SAndroid Build Coastguard Worker
33*7c356e86SAndroid Build Coastguard Workerv=$1
34*7c356e86SAndroid Build Coastguard Workerif test -z "$v"; then
35*7c356e86SAndroid Build Coastguard Worker	v=$(sed $p -n '/^#define MKSH_VERSION "\(.*\)"$/s//\1/p' "$srcdir"/sh.h)
36*7c356e86SAndroid Build Coastguard Workerfi
37*7c356e86SAndroid Build Coastguard Workersrc_id=$(sed $p -n '/^RCSID: /s///p' "$srcdir"/mksh.faq)
38*7c356e86SAndroid Build Coastguard Worker# sanity check
39*7c356e86SAndroid Build Coastguard Workercase $src_id in
40*7c356e86SAndroid Build Coastguard Worker*"$nl"*)
41*7c356e86SAndroid Build Coastguard Worker	echo >&2 "E: more than one RCSID in mksh.faq?"
42*7c356e86SAndroid Build Coastguard Worker	exit 1 ;;
43*7c356e86SAndroid Build Coastguard Workeresac
44*7c356e86SAndroid Build Coastguard Worker
45*7c356e86SAndroid Build Coastguard Workersed $p \
46*7c356e86SAndroid Build Coastguard Worker    -e '/^RCSID: \$/s/^.*$/----/' \
47*7c356e86SAndroid Build Coastguard Worker    -e 's!@@RELPATH@@!http://www.mirbsd.org/!g' \
48*7c356e86SAndroid Build Coastguard Worker    -e 's^	<span style="display:none;">	</span>' \
49*7c356e86SAndroid Build Coastguard Worker    "$srcdir"/mksh.faq | tr '\n' '' | sed $p \
50*7c356e86SAndroid Build Coastguard Worker    -e 'sg' \
51*7c356e86SAndroid Build Coastguard Worker    -e 's----g' \
52*7c356e86SAndroid Build Coastguard Worker    -e 's\([^]*\)\1g' \
53*7c356e86SAndroid Build Coastguard Worker    -e 's\([^]*\)\1g' \
54*7c356e86SAndroid Build Coastguard Worker    -e 's\([^]*\)*ToC: \([^]*\)Title: \([^]*\)\([^]*\)\{0,1\}</div><h2 id="\2"><a href="#\2">\3</a></h2><div>g' \
55*7c356e86SAndroid Build Coastguard Worker    -e 's[^]*</div><div>g' \
56*7c356e86SAndroid Build Coastguard Worker    -e 's^</div>*' \
57*7c356e86SAndroid Build Coastguard Worker    -e 's$</div>' \
58*7c356e86SAndroid Build Coastguard Worker    -e 's<><error><>g' \
59*7c356e86SAndroid Build Coastguard Worker    -e 'sg' | tr '' '\n' >FAQ.tmp
60*7c356e86SAndroid Build Coastguard Worker
61*7c356e86SAndroid Build Coastguard Workerexec >FAQ.htm~
62*7c356e86SAndroid Build Coastguard Workercat <<EOF
63*7c356e86SAndroid Build Coastguard Worker<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
64*7c356e86SAndroid Build Coastguard Worker "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
65*7c356e86SAndroid Build Coastguard Worker<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
66*7c356e86SAndroid Build Coastguard Worker <meta http-equiv="content-type" content="text/html; charset=utf-8" />
67*7c356e86SAndroid Build Coastguard Worker <title>mksh $v FAQ (local copy)</title>
68*7c356e86SAndroid Build Coastguard Worker <meta name="source" content="$src_id" />
69*7c356e86SAndroid Build Coastguard Worker <meta name="generator" content="$rcsid" />
70*7c356e86SAndroid Build Coastguard Worker <style type="text/css"><!--/*--><![CDATA[/*><!--*/
71*7c356e86SAndroid Build Coastguard Worker .boxhead {
72*7c356e86SAndroid Build Coastguard Worker	margin-bottom:0px;
73*7c356e86SAndroid Build Coastguard Worker }
74*7c356e86SAndroid Build Coastguard Worker
75*7c356e86SAndroid Build Coastguard Worker .boxtext {
76*7c356e86SAndroid Build Coastguard Worker	border:4px ridge green;
77*7c356e86SAndroid Build Coastguard Worker	margin:0px 24px 0px 18px;
78*7c356e86SAndroid Build Coastguard Worker	padding:2px 3px 2px 3px;
79*7c356e86SAndroid Build Coastguard Worker }
80*7c356e86SAndroid Build Coastguard Worker
81*7c356e86SAndroid Build Coastguard Worker .boxfoot {
82*7c356e86SAndroid Build Coastguard Worker	margin-top:0px;
83*7c356e86SAndroid Build Coastguard Worker }
84*7c356e86SAndroid Build Coastguard Worker
85*7c356e86SAndroid Build Coastguard Worker h2:before {
86*7c356e86SAndroid Build Coastguard Worker	content:"�� ";
87*7c356e86SAndroid Build Coastguard Worker }
88*7c356e86SAndroid Build Coastguard Worker
89*7c356e86SAndroid Build Coastguard Worker a[href^="ftp://"]:after,
90*7c356e86SAndroid Build Coastguard Worker a[href^="http://"]:after,
91*7c356e86SAndroid Build Coastguard Worker a[href^="https://"]:after,
92*7c356e86SAndroid Build Coastguard Worker a[href^="irc://"]:after,
93*7c356e86SAndroid Build Coastguard Worker a[href^="mailto:"]:after,
94*7c356e86SAndroid Build Coastguard Worker a[href^="news:"]:after,
95*7c356e86SAndroid Build Coastguard Worker a[href^="nntp://"]:after {
96*7c356e86SAndroid Build Coastguard Worker	content:"⏍";
97*7c356e86SAndroid Build Coastguard Worker	color:#FF0000;
98*7c356e86SAndroid Build Coastguard Worker	vertical-align:super;
99*7c356e86SAndroid Build Coastguard Worker	margin:0 0 0 1px;
100*7c356e86SAndroid Build Coastguard Worker }
101*7c356e86SAndroid Build Coastguard Worker
102*7c356e86SAndroid Build Coastguard Worker pre {
103*7c356e86SAndroid Build Coastguard Worker	/*      ↑   →   ↓    ←   */
104*7c356e86SAndroid Build Coastguard Worker	margin:0px 9px 0px 15px;
105*7c356e86SAndroid Build Coastguard Worker }
106*7c356e86SAndroid Build Coastguard Worker
107*7c356e86SAndroid Build Coastguard Worker tt {
108*7c356e86SAndroid Build Coastguard Worker	white-space:nowrap;
109*7c356e86SAndroid Build Coastguard Worker }
110*7c356e86SAndroid Build Coastguard Worker /*]]>*/--></style>
111*7c356e86SAndroid Build Coastguard Worker</head><body>
112*7c356e86SAndroid Build Coastguard Worker<p>Note: Links marked like <a href="irc://chat.freenode.net/!/bin/mksh">this
113*7c356e86SAndroid Build Coastguard Worker one to the mksh IRC channel</a> connect to external resources.</p>
114*7c356e86SAndroid Build Coastguard Worker<p>⚠ <b>Notice:</b> the website will have <a
115*7c356e86SAndroid Build Coastguard Worker href="http://www.mirbsd.org/mksh-faq.htm">the latest version of the
116*7c356e86SAndroid Build Coastguard Worker mksh FAQ</a> online.</p>
117*7c356e86SAndroid Build Coastguard Worker<h1>Table of Contents</h1>
118*7c356e86SAndroid Build Coastguard Worker<ul>
119*7c356e86SAndroid Build Coastguard WorkerEOF
120*7c356e86SAndroid Build Coastguard Workersed $p -n \
121*7c356e86SAndroid Build Coastguard Worker    '/^<h2 id="\([^"]*"\)><a[^>]*\(>.*<\/a><\/\)h2>$/s//<li><a href="#\1\2li>/p' \
122*7c356e86SAndroid Build Coastguard Worker    <FAQ.tmp
123*7c356e86SAndroid Build Coastguard Workercat <<EOF
124*7c356e86SAndroid Build Coastguard Worker</ul>
125*7c356e86SAndroid Build Coastguard Worker
126*7c356e86SAndroid Build Coastguard Worker<h1>Frequently Asked Questions</h1>
127*7c356e86SAndroid Build Coastguard WorkerEOF
128*7c356e86SAndroid Build Coastguard Workercat FAQ.tmp - <<EOF
129*7c356e86SAndroid Build Coastguard Worker<h1>Imprint</h1>
130*7c356e86SAndroid Build Coastguard Worker<p>This offline HTML page for mksh $v was automatically generated
131*7c356e86SAndroid Build Coastguard Worker from the sources.</p>
132*7c356e86SAndroid Build Coastguard Worker</body></html>
133*7c356e86SAndroid Build Coastguard WorkerEOF
134*7c356e86SAndroid Build Coastguard Workerexec >/dev/null
135*7c356e86SAndroid Build Coastguard Workerrm FAQ.tmp
136*7c356e86SAndroid Build Coastguard Workermv FAQ.htm~ FAQ.htm
137