forked from koalaman/shellcheck.net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
251 lines (224 loc) · 8.92 KB
/
index.php
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<html>
<head>
<title>ShellCheck – shell script analysis tool</title>
<link rel="stylesheet" type="text/css" href="shellcheck.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:image" content="shellcheck.png" />
<meta property="og:description" content="ShellCheck finds bugs in your shell scripts" />
<meta name="description" content="ShellCheck is an open source static analysis tool that automatically finds bugs in your shell scripts." />
<script src="bugreport.js"></script>
<script src="shellcheck.js"></script>
<script src="autofix.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
</head>
<body>
<?php
// Content to prepopulate the editor with
$content = "";
if ( isset($_GET["id"]) ) {
$file = preg_replace("/[^a-zA-Z0-9]+/", "", $_GET["id"]);
if ($file != "") {
$content = file_get_contents("./data/$file");
}
}
?>
<div class="demo" style="display: none">#!/bin/sh
## Example: a typical script with several problems
for f in $(ls *.m3u)
do
grep -qi hq.*mp3 $f \
&& echo -e 'Playlist $f contains a HQ file in mp3 format'
done
</div>
<div class="demo" style="display: none">#!/bin/sh
## Example: The shebang says 'sh' so shellcheck warns about portability
## Change it to '#!/bin/bash' to allow bashisms
for n in {1..$RANDOM}
do
str=""
if (( n % 3 == 0 ))
then
str="fizz"
fi
if [ $[n%5] == 0 ]
then
str="$strbuzz"
fi
if [[ ! $str ]]
then
str="$n"
fi
echo "$str"
done
</div>
<div class="demo" style="display: none">#!/bin/bash
## Example: ShellCheck can detect some higher level semantic problems
while getopts "nf:" param
do
case "$param" in
f) file="$OPTARG" ;;
v) set -x ;;
esac
done
case "$file" in
*.gz) gzip -d "$file" ;;
*.zip) unzip "$file" ;;
*.tar.gz) tar xzf "$file" ;;
*) echo "Unknown filetype" ;;
esac
if [[ "$$(uname)" == "Linux" ]]
then
echo "Using Linux"
fi
</div>
<div class="demo" style="display: none">#!/bin/bash
## Example: ShellCheck can detect many different kinds of quoting issues
if ! grep -q backup=true.* "~/.myconfig"
then
echo 'Backup not enabled in $HOME/.myconfig, exiting'
exit 1
fi
if [[ $1 =~ "-v(erbose)?" ]]
then
verbose='-printf "Copying %f\n"'
fi
find backups/ \
-iname *.tar.gz \
$verbose \
-exec scp {} “myhost:backups” +
</div>
<div id="header">
<div id="shellcheck">
</div>
<div id="github">
<a href="https://github.com/koalaman/shellcheck">
<img src="GitHub_Logo.png" style="height: 1.5ex" alt="GitHub" /> ➯
</a>
</div>
</div>
<div class="intro" style="display: none">
<div class="banner">
<div class="logo">
<h1>ShellCheck</h1><br />
finds bugs in your shell scripts.
</div>
</div>
</div>
<div class="contents">
<div class="contentpart">
<h1>ShellCheck</h1><br />
finds bugs in your shell scripts.
</div>
<div class="contentpart">
You can <code>cabal</code>, <code>apt</code>, <code>dnf</code>, <code>pkg</code> or <code>brew install</code> it locally right now.
</div>
<div class="contentpart">
Paste a script to try it out:
</div>
<div class="contentpart">
<div class="window" id="editorwindow">
<div id="titlebar">
<div class="titleitem">📄</div>
<div class="titleitem mainitem">Your Editor (<a href="https://github.com/ajaxorg/ace">Ace</a><span id="downloadingindicator"> – loading 800kb of JS</span>) </div>
<a class="titleitem" href="javascript:minimize()">▼</a>
<div class="titleitem"> </div>
<a class="titleitem" href="javascript:maximize()">▲</a>
</div>
<div class="windowbody">
<div class="menubar">
<a class="titleitem" href="#" onclick="editor.setValue(randomExample(), 1);">Load random example</a>
<div class="titleitem mainitem"></div>
<a id="autofix" class="titleitem miniitem disabledLink" href="javascript:applyAllFixes()">Apply fixes</a>
<span class="titleitem spaceitem"></span>
<a class="titleitem miniitem" href="javascript:reportBug()">Report bug</a>
<span class="titleitem spaceitem"></span>
<a class="titleitem miniitem" href="javascript:alert('Are you on mobile and unable to paste in the editor? Paste in this plaintext box to have it copied over.')">Mobile paste:</a>
<div class="titleitem"><textarea id="pastehack" type="text" rows=1 cols=2 style="vertical-align: middle; display:inline; "></textarea></div><br />
</div>
<pre id="input"><?php echo htmlentities($content) ?></pre>
</div>
</div>
</div>
<div class="contentpart">
<div class="window" id="terminalwindow">
<div id="titlebar">
<div class="titleitem">📄</div>
<div class="titleitem mainitem">
ShellCheck Output
<span id="processingindicator"></span>
</div>
</div>
<div class="windowbody">
<div id="terminal">
If you paste a script in the editor above, this window will show shellcheck output.
</div>
</div>
</div>
</div>
<div class="contentpart">
<h2>ShellCheck is...</h2>
<div class="benefitblock">
<ul>
<li><a href="https://github.com/koalaman/shellcheck/blob/master/LICENSE">GPLv3</a>: free as in freedom</li>
<li>available on <a href="https://github.com/koalaman/shellcheck">GitHub</a> (as is <a href="https://github.com/koalaman/shellcheck.net">this website</a>)</li>
<li>already packaged for your <a href="https://github.com/koalaman/shellcheck#user-content-installing">distro or package manager</a> </li>
<li>supported as an <a href="https://github.com/koalaman/shellcheck#user-content-in-your-editor">integrated linter</a> in major editors</li>
<li>available in <a href="https://codeclimate.com/">CodeClimate</a>, <a href="https://www.codacy.com/">Codacy</a> and <a href="https://www.codefactor.io/">CodeFactor</a> to auto-check your GitHub repo</li>
<li>written in Haskell, if you're into that sort of thing.</li>
</ul>
</div>
</div>
<div class="contentpart">
A special thanks to the <a href="https://github.com/sponsors/koalaman">GitHub Sponsors</a>:
<a href="https://github.com/benliddicott">benliddicott</a>
• <a href="https://gitpod.io">Gitpod</a>
• <a href="https://github.com/aniravi24">aniravi24</a>
• <a href="https://github.com/per1234">per1234</a>
• <a href="https://www.bashsupport.com/pro/">BashSupport Pro</a> <!-- jansorg -->
• <a href="https://github.com/per1234">per1234</a>
• <a href="https://github.com/WhitewaterFoundry">WhitewaterFoundry</a>
• <a href="https://github.com/reap2sow1">reap2sow1</a>
• <a href="https://github.com/dcminter">dcminter</a>
• <a href="https://github.com/photostructure">photostructure</a>
• <a href="https://cronitor.io">Cronitor</a>
• <a href="https://github.com/devholic">devholic</a>
• <a href="https://github.com/qmacro">qmacro</a>
</div>
</div>
<script src="libace/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("input");
editor.session.setMode("ace/mode/sh");
editor.session.setOptions({"tabSize": 8});
editor.setFontSize(12);
editor.on("change", editorChangeHandler);
$(document).ready(function() {
$("#editorwindow").resizable({
start: function(a,b) { $(this).css( {"max-width": "100%" }); },
resize: function(a,b) { editor.resize(); },
minWidth: 200,
minHeight: 50,
});
$("#downloadingindicator").text("");
$("#pastehack").on("change paste keyup", function() {
if ( $("#pastehack").val() != "") {
editor.setValue($("#pastehack").val());
$("#pastehack").val("");
}
});
});
lastRandom = -1;
function randomExample() {
var candidates = $(".demo").toArray();
var selection;
do {
selection = Math.floor(Math.random()*candidates.length);
} while(selection === lastRandom);
lastRandom = selection;
return $(candidates[selection]).text();
}
</script>
</body>
</html>