-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbash.html
More file actions
192 lines (192 loc) · 12.4 KB
/
bash.html
File metadata and controls
192 lines (192 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang xml:lang>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Codebraid with Bash</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<link rel="stylesheet" href="data:text/css,body%20%7Bdisplay%3A%20block%3Btext%2Dalign%3A%20left%3Bmax%2Dwidth%3A%2040rem%3Bpadding%2Dleft%3A%200%2E5rem%3Bpadding%2Dright%3A%200%2E5rem%3Bmargin%3A%20auto%3B%7Dpre%2EnumberSource%20a%2EsourceLine%20%7Bposition%3A%20relative%3Bleft%3A%20%2D3em%3B%7Dpre%2EnumberSource%20a%2EsourceLine%3A%3Abefore%7Bcontent%3A%20attr%28title%29%3Bposition%3A%20relative%3Bleft%3A%20%2D1em%3Btext%2Dalign%3A%20right%3Bvertical%2Dalign%3A%20baseline%3Bborder%3A%20none%3Bpointer%2Devents%3A%20all%3Bdisplay%3A%20inline%2Dblock%3B%2Dwebkit%2Dtouch%2Dcallout%3A%20none%3B%2Dwebkit%2Duser%2Dselect%3A%20none%3B%2Dkhtml%2Duser%2Dselect%3A%20none%3B%2Dmoz%2Duser%2Dselect%3A%20none%3B%2Dms%2Duser%2Dselect%3A%20none%3Buser%2Dselect%3A%20none%3Bpadding%3A%200%204px%3Bwidth%3A%203em%3Bcolor%3A%20%23aaaaaa%3B%7Dpre%2EnumberSource%20%7Bmargin%2Dleft%3A%202em%3Bborder%2Dleft%3A%201px%20solid%20%23aaaaaa%3Bpadding%2Dleft%3A%204px%3B%7Ddiv%2EexampleMarkup%3Abefore%7Bcontent%3A%20%22Markdown%22%3Bfont%2Dfamily%3A%20monospace%3Bdisplay%3A%20block%3Bheight%3A%202em%3Bfont%2Dsize%3A%20150%25%3B%7Ddiv%2EexampleMarkup%20%7Bpadding%2Dtop%3A%200%2E5em%3Bpadding%2Dleft%3A%200%2E5em%3Bpadding%2Dright%3A%200%2E5em%3Bmargin%2Dtop%3A%202em%3Bmargin%2Dbottom%3A%201em%3Bbackground%2Dcolor%3A%20honeydew%3Bborder%2Dstyle%3A%20solid%3Bborder%2Dwidth%3A%201px%3Bborder%2Dcolor%3A%20limegreen%3Bborder%2Dradius%3A%200%2E2em%3B%7Ddiv%2EexampleOutput%3Abefore%7Bcontent%3A%20%22Output%22%3Bfont%2Dfamily%3A%20monospace%3Bdisplay%3A%20block%3Bfont%2Dsize%3A%20150%25%3B%7Ddiv%2EexampleOutput%20%7Bcolor%3A%20black%3Bpadding%2Dtop%3A%200%2E5em%3Bpadding%2Dleft%3A%200%2E5em%3Bpadding%2Dright%3A%200%2E5em%3Bmargin%2Dtop%3A%201em%3Bmargin%2Dbottom%3A%202em%3Bbackground%2Dcolor%3A%20whitesmoke%3Bborder%2Dstyle%3A%20solid%3Bborder%2Dwidth%3A%201px%3Bborder%2Dcolor%3A%20lightgray%3Bborder%2Dradius%3A%200%2E2em%3B%7Ddiv%2EsourceCode%20%7Bpadding%3A%200%2E5em%3Bbackground%2Dcolor%3A%20aliceblue%3Bborder%2Dstyle%3A%20solid%3Bborder%2Dwidth%3A%201px%3Bborder%2Dcolor%3A%20lightskyblue%3Bborder%2Dradius%3A%200%2E2em%3B%7Ddiv%2EexampleOutput%20div%2EsourceCode%3Abefore%7Bcontent%3A%20%22code%22%3Bfont%2Dfamily%3A%20monospace%3Bdisplay%3A%20block%3Bheight%3A%202em%3Bfont%2Dweight%3A%20bold%3Bfont%2Dsize%3A%20120%25%3B%7Dpre%2Estdout%3Abefore%7Bcontent%3A%20%22stdout%22%3Bdisplay%3A%20block%3Bheight%3A%202em%3Bfont%2Dweight%3A%20bold%3Bfont%2Dsize%3A%20120%25%3B%7Dpre%2Estdout%20%7Bcolor%3A%20black%3Bpadding%3A%200%2E5em%3Bbackground%2Dcolor%3A%20azure%3Bborder%2Dstyle%3A%20solid%3Bborder%2Dwidth%3A%201px%3Bborder%2Dcolor%3A%20turquoise%3Bborder%2Dradius%3A%200%2E2em%3Bpadding%2Dleft%3A%200%2E5em%3B%7Dcode%2Estdout%20%7Bcolor%3A%20black%3Bbackground%2Dcolor%3A%20azure%3Bborder%2Dstyle%3A%20solid%3Bborder%2Dwidth%3A%201px%3Bborder%2Dcolor%3A%20turquoise%3B%7Dpre%2Estderr%3Abefore%7Bcontent%3A%20%22stderr%22%3Bdisplay%3A%20block%3Bheight%3A%202em%3Bfont%2Dweight%3A%20bold%3Bfont%2Dsize%3A%20120%25%3B%7Dpre%2Estderr%20%7Bcolor%3A%20red%3Bpadding%3A%200%2E5em%3Bbackground%2Dcolor%3A%20lavenderblush%3Bborder%2Dstyle%3A%20solid%3Bborder%2Dwidth%3A%201px%3Bborder%2Dcolor%3A%20pink%3Bborder%2Dradius%3A%200%2E2em%3Bpadding%2Dleft%3A%200%2E5em%3B%7Dcode%2Estderr%20%7Bcolor%3A%20red%3Bbackground%2Dcolor%3A%20lavenderblush%3Bborder%2Dstyle%3A%20solid%3Bborder%2Dwidth%3A%201px%3Bborder%2Dcolor%3A%20pink%3B%7Dpre%2EsourceError%3Abefore%7Bcontent%3A%20%22Source%20error%22%3Bdisplay%3A%20block%3Bheight%3A%202em%3Bfont%2Dweight%3A%20bold%3Bfont%2Dsize%3A%20120%25%3B%7Dpre%2EsourceError%20%7Bcolor%3A%20red%3Bpadding%3A%200%2E5em%3Bbackground%2Dcolor%3A%20lavenderblush%3Bborder%2Dstyle%3A%20solid%3Bborder%2Dwidth%3A%201px%3Bborder%2Dcolor%3A%20pink%3Bborder%2Dradius%3A%200%2E2em%3Bpadding%2Dleft%3A%200%2E5em%3B%7Dcode%2EsourceError%20%7Bcolor%3A%20red%3Bbackground%2Dcolor%3A%20lavenderblush%3Bborder%2Dstyle%3A%20solid%3Bborder%2Dwidth%3A%201px%3Bborder%2Dcolor%3A%20pink%3B%7D" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<header id="title-block-header">
<h1 class="title">Codebraid with Bash</h1>
</header>
<h2 id="inline-code">Inline code</h2>
<h3 id="run">Run</h3>
<p>Inline code with <code>.cb.run</code> gives raw stdout.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>`echo $((1 + 2))`{.bash .cb.run}</code></pre>
</div>
<div class="exampleOutput">
<p>3</p>
</div>
</div>
<h3 id="expression-and-inline-notebook">Expression and inline notebook</h3>
<p>Inline code with <code>.cb.expr</code> evaluates an expression and then inserts the raw output into the document, where it is interpreted as Markdown. Inline code with <code>.cb.nb</code> (<code>nb</code> is short for <code>notebook</code>) is similar, except output is shown verbatim. Expressions are evaluated via <code>$(<expr>)</code>.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>`(4 * 16)`{.bash .cb.expr}</code></pre>
</div>
<div class="exampleOutput">
<p>64</p>
</div>
</div>
<div class="example">
<div class="exampleMarkup">
<pre><code>`ls | grep "bash\.cbmd"`{.bash .cb.nb}</code></pre>
</div>
<div class="exampleOutput">
<p><code class="expr">bash.cbmd</code></p>
</div>
</div>
<h3 id="stderr">Stderr</h3>
<p>In the event of an error, inline code automatically shows stderr by default. This code is executed in its own session, <code>inline_error</code>, so that it does not impact other examples.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>`echooo $((1 + 2))`{.bash .cb.run session=inline_error}</code></pre>
</div>
<div class="exampleOutput">
<p><code class="stderr"><string>: line 1: echooo: command not found</code></p>
</div>
</div>
<h2 id="block-code">Block code</h2>
<h3 id="run-1">Run</h3>
<p>Code blocks with <code>.cb.run</code> give raw stdout. There is continuity between code blocks so long as they are in the same session; variables persist.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.bash .cb.run}
message="Hello from *Bash!*"
```</code></pre>
</div>
</div>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.bash .cb.run}
echo "$message"
```</code></pre>
</div>
<div class="exampleOutput">
<p>Hello from <em>Bash!</em></p>
</div>
</div>
<h3 id="notebook">Notebook</h3>
<p>Code blocks with <code>.cb.nb</code> show the code and also the verbatim stdout.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.bash .cb.nb session=notebook}
ls | grep "bash"
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb8" data-startFrom="1"><pre class="sourceCode numberSource bash numberLines"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1"></a><span class="fu">ls</span> <span class="kw">|</span> <span class="fu">grep</span> <span class="st">"bash"</span></span></code></pre></div>
<pre class="stdout"><code>bash.cbmd
bash.html
build_bash.sh</code></pre>
</div>
</div>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.bash .cb.nb session=notebook}
which python3 && which python
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb11" data-startFrom="2"><pre class="sourceCode numberSource bash numberLines"><code class="sourceCode bash" style="counter-reset: source-line 1;"><span id="cb11-2"><a href="#cb11-2"></a><span class="fu">which</span> python3 <span class="kw">&&</span> <span class="fu">which</span> python</span></code></pre></div>
<pre class="stdout"><code>/usr/bin/python3</code></pre>
</div>
</div>
<h3 id="stderr-1">Stderr</h3>
<p>Code blocks show stderr automatically by default.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.bash .cb.nb session=block_error}
set -u
var="$((1 + 2))"
echo "$varrr"
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb14" data-startFrom="1"><pre class="sourceCode numberSource bash numberLines"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1"></a><span class="bu">set</span> <span class="at">-u</span></span>
<span id="cb14-2"><a href="#cb14-2"></a><span class="va">var=</span><span class="st">"</span><span class="va">$((</span><span class="dv">1</span> <span class="op">+</span> <span class="dv">2</span><span class="va">))</span><span class="st">"</span></span>
<span id="cb14-3"><a href="#cb14-3"></a><span class="bu">echo</span> <span class="st">"</span><span class="va">$varrr</span><span class="st">"</span></span></code></pre></div>
<pre class="stderr"><code>source.sh: line 3: varrr: unbound variable</code></pre>
</div>
</div>
</body>
</html>