Gentoo Archives: gentoo-portage-dev

From: R0b0t1 <r030t1@×××××.com>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] Fix all misc. bash errors.
Date: Mon, 05 Feb 2018 03:22:22
Message-Id: CAAD4mYhzpiQUBPpQ4t=2buWyQsquc3DmTYTy7yBRO8gUe0QWWw@mail.gmail.com
1 This is everything that shellcheck reported as an error. They are not
2 as serious as the globbing issue, but it would be a good idea to
3 change them. They are generally "type" issues (e.g. ">" instead of
4 "-gt").
5
6 Some changes are shellcheck annotations. Very interesting was:
7
8 eval "$x=(\"\${$x[@]}\" ${QA_PREBUILT//\*/.*})"
9
10 Which looks like a bad array expansion ("$x[@]").
11
12 Cheers,
13 R0b0t1
14
15
16 ---
17 bin/ebuild-helpers/newins | 2 +-
18 bin/ebuild.sh | 2 +-
19 bin/etc-update | 6 +++---
20 bin/isolated-functions.sh | 6 +++---
21 bin/phase-functions.sh | 1 +
22 5 files changed, 9 insertions(+), 8 deletions(-)
23
24 diff --git a/bin/ebuild-helpers/newins b/bin/ebuild-helpers/newins
25 index 8032a8f2f..30e54b7e5 100755
26 --- a/bin/ebuild-helpers/newins
27 +++ b/bin/ebuild-helpers/newins
28 @@ -12,7 +12,7 @@ if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
29 fi
30
31 (($#>2)) && \
32 - eqawarn "QA Notice: ${helper} called with more than 2 arguments: ${@:3}"
33 + eqawarn "QA Notice: ${helper} called with more than 2 arguments: ${*:3}"
34
35 stdin=
36 if ___eapi_newins_supports_reading_from_standard_input && [[ $1 == "-" ]]; then
37 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
38 index 94a44d534..4a80fdd06 100755
39 --- a/bin/ebuild.sh
40 +++ b/bin/ebuild.sh
41 @@ -232,7 +232,7 @@ debug-print-section() {
42 declare -ix ECLASS_DEPTH=0
43 inherit() {
44 ECLASS_DEPTH=$(($ECLASS_DEPTH + 1))
45 - if [[ ${ECLASS_DEPTH} > 1 ]]; then
46 + if [[ ${ECLASS_DEPTH} -gt 1 ]]; then
47 debug-print "*** Multiple Inheritence (Level: ${ECLASS_DEPTH})"
48 fi
49
50 diff --git a/bin/etc-update b/bin/etc-update
51 index ea69f1478..cbca8217e 100755
52 --- a/bin/etc-update
53 +++ b/bin/etc-update
54 @@ -767,7 +767,7 @@ portage_vars=(
55 )
56
57 if type -P portageq > /dev/null; then
58 - eval $(${PORTAGE_PYTHON:+"${PORTAGE_PYTHON}"} "$(type -P
59 portageq)" envvar -v ${portage_vars[@]})
60 + eval $(${PORTAGE_PYTHON:+"${PORTAGE_PYTHON}"} "$(type -P
61 portageq)" envvar -v "${portage_vars[@]}")
62 else
63 [[ $OS_FAMILY == 'gentoo' ]] && die "missing portageq"
64 fi
65 @@ -801,7 +801,7 @@ cfg_vars=(
66 mode
67 )
68 # default them all to ""
69 -eval ${cfg_vars[@]/%/=}
70 +eval "${cfg_vars[@]/%/=}"
71 # then extract them all from the conf in one shot
72 # (ugly var at end is due to printf appending a '|' to last item)
73 get_config "($(printf '%s|' "${cfg_vars[@]}")NOVARFOROLDMEN)"
74 @@ -846,7 +846,7 @@ if ${NONINTERACTIVE_MV} ; then
75 fi
76
77 if ${VERBOSE} ; then
78 - for v in ${portage_vars[@]} ${cfg_vars[@]} TMP SCAN_PATHS ; do
79 + for v in "${portage_vars[@]} ${cfg_vars[@]} TMP SCAN_PATHS" ; do
80 echo "${v}=${!v}"
81 done
82 fi
83 diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
84 index b28e44f18..377b32d90 100644
85 --- a/bin/isolated-functions.sh
86 +++ b/bin/isolated-functions.sh
87 @@ -82,7 +82,7 @@ __dump_trace() {
88 lineno=${BASH_LINENO[${n} - 1]}
89 # Display function arguments
90 args=
91 - if [[ -n "${BASH_ARGV[@]}" ]]; then
92 + if [[ -n "${BASH_ARGV[*]}" ]]; then
93 for (( j = 1 ; j <= ${BASH_ARGC[${n} - 1]} ; ++j )); do
94 newarg=${BASH_ARGV[$(( p - j - 1 ))]}
95 args="${args:+${args} }'${newarg}'"
96 @@ -550,13 +550,13 @@ __eqatag() {
97
98 (
99 echo "- tag: ${tag}"
100 - if [[ ${data[@]} ]]; then
101 + if [[ ${data[*]} ]]; then
102 echo " data:"
103 for i in "${data[@]}"; do
104 echo " ${i%%=*}: \"$(__eqaquote "${i#*=}")\""
105 done
106 fi
107 - if [[ ${filenames[@]} ]]; then
108 + if [[ ${filenames[*]} ]]; then
109 echo " files:"
110 for i in "${filenames[@]}"; do
111 echo " - \"$(__eqaquote "${i}")\""
112 diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
113 index 10d54ca74..469715f7f 100644
114 --- a/bin/phase-functions.sh
115 +++ b/bin/phase-functions.sh
116 @@ -541,6 +541,7 @@ __dyn_install() {
117 # fnmatch patterns to regular expressions
118 for x in QA_DT_NEEDED QA_FLAGS_IGNORED QA_PRESTRIPPED QA_SONAME ; do
119 if [[ $(declare -p $x 2>/dev/null) = declare\ -a* ]] ; then
120 + # shellcheck disable=1087
121 eval "$x=(\"\${$x[@]}\" ${QA_PREBUILT//\*/.*})"
122 else
123 eval "$x+=\" ${QA_PREBUILT//\*/.*}\""
124 --
125 2.14.1

Attachments

File name MIME type
fix-misc-bash.patch text/x-patch
portcheck.tar.xz application/x-xz

Replies

Subject Author
Re: [gentoo-portage-dev] Fix all misc. bash errors. Zac Medico <zmedico@g.o>