1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Called from the end of html-summary in test/spec-runner.sh.
|
4 | #
|
5 | # Usage:
|
6 | # test/spec-version.sh <function name>
|
7 |
|
8 | set -o nounset
|
9 | set -o pipefail
|
10 | set -o errexit
|
11 |
|
12 | REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
|
13 |
|
14 | source devtools/run-task.sh
|
15 | source test/common.sh # date-and-git-info
|
16 | source test/spec-common.sh # OSH_LIST
|
17 |
|
18 | maybe-show() {
|
19 | local path=$1
|
20 | if test -f $path; then
|
21 | echo "--- $path ---"
|
22 | cat $path
|
23 | echo
|
24 | fi
|
25 | }
|
26 |
|
27 | ysh-version-text() {
|
28 | date-and-git-info
|
29 |
|
30 | for bin in $YSH_LIST; do
|
31 | echo ---
|
32 | echo "\$ $bin --version"
|
33 | $bin --version
|
34 | echo
|
35 | done
|
36 |
|
37 | maybe-show /etc/alpine-release
|
38 | maybe-show /etc/debian_version
|
39 | maybe-show /etc/lsb-release
|
40 | }
|
41 |
|
42 | tea-version-text() {
|
43 | ysh-version-text
|
44 | }
|
45 |
|
46 | # TODO: Refactor this so you get the shells
|
47 | # test/sh_spec.py --shells
|
48 | # And then do 'bash dash mksh zsh ash' IF they exist?
|
49 | # That should be fine because we do check-survey-shells BEFORE running
|
50 |
|
51 | osh-version-text() {
|
52 |
|
53 | local -a osh_list
|
54 | if test $# -eq 0; then
|
55 | osh_list=( $OSH_LIST ) # word splitting
|
56 | else
|
57 | osh_list=( "$@" ) # explicit arguments
|
58 | fi
|
59 |
|
60 | date-and-git-info
|
61 |
|
62 | for bin in "${osh_list[@]}"; do
|
63 | echo ---
|
64 | echo "\$ $bin --version"
|
65 | $bin --version
|
66 | echo
|
67 | done
|
68 |
|
69 | # $BASH and $ZSH should exist
|
70 |
|
71 | echo ---
|
72 | bash --version | head -n 1
|
73 | ls -l $(type -p bash)
|
74 | echo
|
75 |
|
76 | echo ---
|
77 | zsh --version | head -n 1
|
78 | ls -l $(type -p zsh)
|
79 | echo
|
80 |
|
81 | # No -v or -V or --version. TODO: Only use hermetic version on release.
|
82 |
|
83 | echo ---
|
84 | local my_dash
|
85 | my_dash=$(type -p dash)
|
86 | if test -f $my_dash; then
|
87 | ls -l $my_dash
|
88 | else
|
89 | dpkg -s dash | egrep '^Package|Version'
|
90 | fi
|
91 | echo
|
92 |
|
93 | echo ---
|
94 | local my_mksh
|
95 | my_mksh=$(type -p mksh)
|
96 | if test -f $my_mksh; then
|
97 | ls -l $my_mksh
|
98 | else
|
99 | dpkg -s mksh | egrep '^Package|Version'
|
100 | fi
|
101 | echo
|
102 |
|
103 | echo ---
|
104 | local my_busybox
|
105 | my_busybox=$(type -p busybox)
|
106 | if test -f $my_busybox; then
|
107 | { $my_busybox || true; } | head -n 1
|
108 | ls -l $my_busybox
|
109 | else
|
110 | # Need || true because of pipefail
|
111 | { busybox || true; } | head -n 1
|
112 | fi
|
113 | echo
|
114 |
|
115 | maybe-show /etc/debian_version
|
116 | maybe-show /etc/lsb-release
|
117 | maybe-show /etc/alpine-release
|
118 | }
|
119 |
|
120 | osh-minimal-version-text() {
|
121 | osh-version-text
|
122 | }
|
123 |
|
124 | interactive-version-text() {
|
125 | osh-version-text
|
126 | }
|
127 |
|
128 | run-task "$@"
|