File: shell.html

package info (click to toggle)
rainbow.js 2.1.7%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 1,148 kB
  • sloc: javascript: 4,771; makefile: 13
file content (433 lines) | stat: -rw-r--r-- 10,940 bytes parent folder | download | duplicates (3)
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<!DOCTYPE html>
<html>
  <head>
    <title>ruby-build</title>
    <link href="../themes/css/blackboard.css" rel="stylesheet">
  </head>
  <body>
    <pre>
<code data-language="shell">#!/usr/bin/env bash
# Copyright (c) 2011 Sam Stephenson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# &quot;Software&quot;), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

RUBY_BUILD_VERSION=&quot;20120216&quot;

set -E
exec 3&lt;&amp;2 # preserve original stderr at fd 3

resolve_link() {
  $(type -p greadlink readlink | head -1) &quot;$1&quot;
}

abs_dirname() {
  local cwd=&quot;$(pwd)&quot;
  local path=&quot;$1&quot;

  while [ -n &quot;$path&quot; ]; do
    cd &quot;${path%/*}&quot;
    local name=&quot;${path##*/}&quot;
    path=&quot;$(resolve_link &quot;$name&quot; || true)&quot;
  done

  pwd
  cd &quot;$cwd&quot;
}

build_failed() {
  { echo
    echo &quot;BUILD FAILED&quot;
    echo

    if ! rmdir &quot;${TEMP_PATH}&quot; 2&gt;/dev/null; then
      echo &quot;Inspect or clean up the working tree at ${TEMP_PATH}&quot;

      if file_is_not_empty &quot;$LOG_PATH&quot;; then
        echo &quot;Results logged to ${LOG_PATH}&quot;
        echo
        echo &quot;Last 10 log lines:&quot;
        tail -n 10 &quot;$LOG_PATH&quot;
      fi
    fi
  } &gt;&amp;3
  exit 1
}

file_is_not_empty() {
  local filename=&quot;$1&quot;
  local line_count=&quot;$(wc -l &quot;$filename&quot; 2&gt;/dev/null || true)&quot;

  if [ -n &quot;$line_count&quot; ]; then
    words=( $line_count )
    [ &quot;${words[0]}&quot; -gt 0 ]
  else
    return 1
  fi
}

install_package() {
  install_package_using &quot;tarball&quot; 1 $*
}

install_git() {
  install_package_using &quot;git&quot; 2 $*
}

install_package_using() {
  local package_type=&quot;$1&quot;
  local package_type_nargs=&quot;$2&quot;
  local package_name=&quot;$3&quot;
  shift 3

  pushd &quot;$TEMP_PATH&quot; &gt;&amp;4
  &quot;fetch_${package_type}&quot; &quot;$package_name&quot; $*
  shift $(($package_type_nargs))
  make_package &quot;$package_name&quot; $*
  popd &gt;&amp;4

  echo &quot;Installed ${package_name} to ${PREFIX_PATH}&quot; &gt;&amp;2
}

make_package() {
  local package_name=&quot;$1&quot;
  shift

  pushd &quot;$package_name&quot; &gt;&amp;4
  before_install_package &quot;$package_name&quot;
  build_package &quot;$package_name&quot; $*
  after_install_package &quot;$package_name&quot;
  fix_directory_permissions
  popd &gt;&amp;4
}

fetch_tarball() {
  local package_name=&quot;$1&quot;
  local package_url=&quot;$2&quot;

  echo &quot;Downloading ${package_url}...&quot; &gt;&amp;2
  { curl &quot;$package_url&quot; &gt; &quot;${package_name}.tar.gz&quot;
    tar xzvf &quot;${package_name}.tar.gz&quot;
  } &gt;&amp;4 2&gt;&amp;1
}

fetch_git() {
  local package_name=&quot;$1&quot;
  local git_url=&quot;$2&quot;
  local git_ref=&quot;$3&quot;

  echo &quot;Cloning ${git_url}...&quot; &gt;&amp;2
  { git clone --depth 1 --branch &quot;$git_ref&quot; &quot;$git_url&quot; &quot;${package_name}&quot;
  } &gt;&amp;4 2&gt;&amp;1
}

build_package() {
  local package_name=&quot;$1&quot;
  shift

  if [ &quot;$#&quot; -eq 0 ]; then
    local commands=&quot;standard&quot;
  else
    local commands=&quot;$*&quot;
  fi

  echo &quot;Installing ${package_name}...&quot; &gt;&amp;2

  for command in $commands; do
    &quot;build_package_${command}&quot;
  done
}

build_package_standard() {
  local package_name=&quot;$1&quot;

  if [ -z &quot;${MAKEOPTS+defined}&quot; ]; then
    MAKE_OPTS=&quot;$MAKEOPTS&quot;
  elif [ -z &quot;${MAKE_OPTS+defined}&quot; ]; then
    MAKE_OPTS=&quot;-j 2&quot;
  fi

  { ./configure --prefix=&quot;$PREFIX_PATH&quot; $CONFIGURE_OPTS
    make $MAKE_OPTS
    make install
  } &gt;&amp;4 2&gt;&amp;1
}

build_package_autoconf() {
  { autoconf
  } &gt;&amp;4 2&gt;&amp;1
}

build_package_ruby() {
  local package_name=&quot;$1&quot;

  { &quot;$RUBY_BIN&quot; setup.rb
  } &gt;&amp;4 2&gt;&amp;1
}

build_package_ree_installer() {
  local options=&quot;&quot;
  if [[ &quot;Darwin&quot; = &quot;$(uname)&quot; ]]; then
    options=&quot;--no-tcmalloc&quot;
  fi

  # Work around install_useful_libraries crash with --dont-install-useful-gems
  mkdir -p &quot;$PREFIX_PATH/lib/ruby/gems/1.8/gems&quot;

  { ./installer --auto &quot;$PREFIX_PATH&quot; --dont-install-useful-gems $options $CONFIGURE_OPTS
  } &gt;&amp;4 2&gt;&amp;1
}

build_package_rbx() {
  local package_name=&quot;$1&quot;

  { ./configure --prefix=&quot;$PREFIX_PATH&quot; --gemsdir=&quot;$PREFIX_PATH&quot;
    rake install
  } &gt;&amp;4 2&gt;&amp;1
}

build_package_maglev() {
  build_package_copy

  { cd &quot;${PREFIX_PATH}&quot;
    ./install.sh
    cd &quot;${PREFIX_PATH}/bin&quot;
    echo &quot;Creating symlink for ruby*&quot;
    ln -fs maglev-ruby ruby
    echo &quot;Creating symlink for irb*&quot;
    ln -fs maglev-irb irb
  } &gt;&amp;4 2&gt;&amp;1
  echo
  echo &quot;Run &#39;maglev start&#39; to start up the stone before using &#39;ruby&#39; or &#39;irb&#39;&quot;
}

build_package_jruby() {
  build_package_copy
  cd &quot;${PREFIX_PATH}/bin&quot;
  ln -fs jruby ruby
  install_jruby_launcher
  remove_windows_files
}

install_jruby_launcher() {
  cd &quot;${PREFIX_PATH}/bin&quot;
  { ./ruby gem install jruby-launcher
  } &gt;&amp;4 2&gt;&amp;1
}

remove_windows_files() {
  cd &quot;$PREFIX_PATH&quot;
  rm -f bin/*.exe bin/*.dll bin/*.bat bin/jruby.sh
}

build_package_copy() {
  mkdir -p &quot;$PREFIX_PATH&quot;
  cp -R . &quot;$PREFIX_PATH&quot;
}

before_install_package() {
  local stub=1
}

after_install_package() {
  local stub=1
}

fix_directory_permissions() {
  # Ensure installed directories are not world-writable to avoid Bundler warnings
  find &quot;$PREFIX_PATH&quot; -type d -exec chmod go-w {} \;
}

require_gcc() {
  local gcc=&quot;$(locate_gcc || true)&quot;
  if [ -z &quot;$gcc&quot; ]; then
    { echo
      echo &quot;ERROR: This package must be compiled with GCC, and we&quot;
      echo &quot;couldn&#39;t find a suitable \`gcc&#39; binary on your system.&quot;
      echo &quot;Please install GCC and try again.&quot;
      echo

      if [ &quot;$(uname -s)&quot; = &quot;Darwin&quot; ]; then
        echo &quot;As of version 4.2, Xcode is LLVM-only and no longer&quot;
        echo &quot;includes GCC. You can install GCC with these binary&quot;
        echo &quot;packages on Mac OS X:&quot;
        echo
        echo &quot;https://github.com/kennethreitz/osx-gcc-installer/downloads&quot;
        echo
      fi
    } &gt;&amp;3
    return 1
  fi

  export CC=&quot;$gcc&quot;
}

locate_gcc() {
  local gcc gccs
  IFS=: gccs=($(gccs_in_path))

  verify_gcc &quot;$CC&quot; ||
  verify_gcc &quot;$(command -v gcc || true)&quot; || {
    for gcc in &quot;${gccs[@]}&quot;; do
      verify_gcc &quot;$gcc&quot; &amp;&amp; break || true
    done
  }

  return 1
}

gccs_in_path() {
  local gcc path paths
  local gccs=()
  IFS=: paths=($PATH)

  shopt -s nullglob
  for path in &quot;${paths[@]}&quot;; do
    for gcc in &quot;$path&quot;/gcc-*; do
      gccs[&quot;${#gccs[@]}&quot;]=&quot;$gcc&quot;
    done
  done
  shopt -u nullglob

  printf :%s &quot;${gccs[@]}&quot;
}

verify_gcc() {
  local gcc=&quot;$1&quot;
  if [ -z &quot;$gcc&quot; ]; then
    return 1
  fi

  local version=&quot;$(&quot;$gcc&quot; --version || true)&quot;
  if [ -z &quot;$version&quot; ]; then
    return 1
  fi

  if echo &quot;$version&quot; | grep LLVM &gt;/dev/null; then
    return 1
  fi

  echo &quot;$gcc&quot;
}

version() {
  echo &quot;ruby-build ${RUBY_BUILD_VERSION}&quot;
}

usage() {
  { version
    echo &quot;usage: ruby-build [-v|--verbose] definition prefix&quot;
    echo &quot;       ruby-build --definitions&quot;
  } &gt;&amp;2

  if [ -z &quot;$1&quot; ]; then
    exit 1
  fi
}

list_definitions() {
  { for definition in &quot;${RUBY_BUILD_ROOT}/share/ruby-build/&quot;*; do
      echo &quot;${definition##*/}&quot;
    done
  } | sort
}



unset VERBOSE
RUBY_BUILD_ROOT=&quot;$(abs_dirname &quot;$0&quot;)/..&quot;

case &quot;$1&quot; in
&quot;-h&quot; | &quot;--help&quot; )
  usage without_exiting
  { echo
    echo &quot;  -v/--verbose     Verbose mode: print compilation status to stdout&quot;
    echo &quot;  --definitions    List all built-in definitions&quot;
    echo
  } &gt;&amp;2
  exit 0
  ;;
&quot;--definitions&quot; )
  list_definitions
  exit 0
  ;;
&quot;--version&quot; )
  version
  exit 0
  ;;
&quot;-v&quot; | &quot;--verbose&quot; )
  VERBOSE=true
  shift
  ;;
esac


DEFINITION_PATH=&quot;$1&quot;
if [ -z &quot;$DEFINITION_PATH&quot; ]; then
  usage
elif [ ! -e &quot;$DEFINITION_PATH&quot; ]; then
  BUILTIN_DEFINITION_PATH=&quot;${RUBY_BUILD_ROOT}/share/ruby-build/${DEFINITION_PATH}&quot;
  if [ -e &quot;$BUILTIN_DEFINITION_PATH&quot; ]; then
    DEFINITION_PATH=&quot;$BUILTIN_DEFINITION_PATH&quot;
  else
    echo &quot;ruby-build: definition not found: ${DEFINITION_PATH}&quot; &gt;&amp;2
    exit 1
  fi
fi

PREFIX_PATH=&quot;$2&quot;
if [ -z &quot;$PREFIX_PATH&quot; ]; then
  usage
fi

if [ -z &quot;$TMPDIR&quot; ]; then
  TMP=&quot;/tmp&quot;
else
  TMP=&quot;${TMPDIR%/}&quot;
fi

SEED=&quot;$(date &quot;+%Y%m%d%H%M%S&quot;).$$&quot;
LOG_PATH=&quot;${TMP}/ruby-build.${SEED}.log&quot;
TEMP_PATH=&quot;${TMP}/ruby-build.${SEED}&quot;
RUBY_BIN=&quot;${PREFIX_PATH}/bin/ruby&quot;
CWD=&quot;$(pwd)&quot;

exec 4&lt;&gt; &quot;$LOG_PATH&quot; # open the log file at fd 4
if [ -n &quot;$VERBOSE&quot; ]; then
  tail -f &quot;$LOG_PATH&quot; &amp;
  trap &quot;kill 0&quot; SIGINT SIGTERM EXIT
fi

export LDFLAGS=&quot;-L&#39;${PREFIX_PATH}/lib&#39; ${LDFLAGS}&quot;
export CPPFLAGS=&quot;-I&#39;${PREFIX_PATH}/include&#39; ${CPPFLAGS}&quot;

unset RUBYOPT
unset RUBYLIB

trap build_failed ERR
mkdir -p &quot;$TEMP_PATH&quot;
source &quot;$DEFINITION_PATH&quot;
rm -fr &quot;$TEMP_PATH&quot;
trap - ERR
</code></pre>
    <script src="../dist/rainbow.js"></script>
    <script src="../src/language/generic.js"></script>
    <script src="../src/language/shell.js"></script>
  </body>
</html>