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