Lines 1-3
Link Here
|
|
|
1 |
# shellcheck shell=sh disable=2039 |
1 |
# Copyright 1999-2014 Gentoo Foundation |
2 |
# Copyright 1999-2014 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
|
4 |
|
Lines 6-11
Link Here
|
6 |
# not use bashisms. |
7 |
# not use bashisms. |
7 |
# |
8 |
# |
8 |
|
9 |
|
|
|
10 |
# shellcheck disable=SC2034 |
9 |
RC_GOT_FUNCTIONS="yes" |
11 |
RC_GOT_FUNCTIONS="yes" |
10 |
|
12 |
|
11 |
# |
13 |
# |
Lines 23-28
Link Here
|
23 |
# |
25 |
# |
24 |
# increase the indent used for e-commands. |
26 |
# increase the indent used for e-commands. |
25 |
# |
27 |
# |
|
|
28 |
# shellcheck disable=SC2120 |
26 |
eindent() |
29 |
eindent() |
27 |
{ |
30 |
{ |
28 |
local i="$1" |
31 |
local i="$1" |
Lines 33-38
Link Here
|
33 |
# |
36 |
# |
34 |
# decrease the indent used for e-commands. |
37 |
# decrease the indent used for e-commands. |
35 |
# |
38 |
# |
|
|
39 |
# shellcheck disable=SC2120 |
36 |
eoutdent() |
40 |
eoutdent() |
37 |
{ |
41 |
{ |
38 |
local i="$1" |
42 |
local i="$1" |
Lines 55-61
Link Here
|
55 |
esac |
59 |
esac |
56 |
|
60 |
|
57 |
local value= |
61 |
local value= |
58 |
eval value=\$${1} |
62 |
eval value="\$${1}" |
59 |
case "$value" in |
63 |
case "$value" in |
60 |
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; |
64 |
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; |
61 |
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; |
65 |
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; |
Lines 95-101
Link Here
|
95 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
99 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
96 |
printf "\n" |
100 |
printf "\n" |
97 |
fi |
101 |
fi |
98 |
printf " ${GOOD}*${NORMAL} ${RC_INDENTATION}$*" |
102 |
printf ' %b*%b %s%s' "${GOOD}" "${NORMAL}" "${RC_INDENTATION}" "${*}" |
99 |
LAST_E_CMD="einfon" |
103 |
LAST_E_CMD="einfon" |
100 |
return 0 |
104 |
return 0 |
101 |
} |
105 |
} |
Lines 121-127
Link Here
|
121 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
125 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
122 |
printf "\n" >&2 |
126 |
printf "\n" >&2 |
123 |
fi |
127 |
fi |
124 |
printf " ${WARN}*${NORMAL} ${RC_INDENTATION}$*" >&2 |
128 |
printf ' %b*%b %s%s' "${WARN}" "${NORMAL}" "${RC_INDENTATION}" "${*}" >&2 |
125 |
fi |
129 |
fi |
126 |
|
130 |
|
127 |
local name="${0##*/}" |
131 |
local name="${0##*/}" |
Lines 143-149
Link Here
|
143 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
147 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
144 |
printf "\n" >&2 |
148 |
printf "\n" >&2 |
145 |
fi |
149 |
fi |
146 |
printf " ${WARN}*${NORMAL} ${RC_INDENTATION}$*\n" >&2 |
150 |
printf ' %b*%b %s%b\n' "${WARN}" "${NORMAL}" "${RC_INDENTATION}" "${*}" >&2 |
147 |
fi |
151 |
fi |
148 |
|
152 |
|
149 |
local name="${0##*/}" |
153 |
local name="${0##*/}" |
Lines 165-171
Link Here
|
165 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
169 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
166 |
printf "\n" >&2 |
170 |
printf "\n" >&2 |
167 |
fi |
171 |
fi |
168 |
printf " ${BAD}*${NORMAL} ${RC_INDENTATION}$*" >&2 |
172 |
printf ' %b*%b %s%s' "${BAD}" "${NORMAL}" "${RC_INDENTATION}" "${*}" >&2 |
169 |
fi |
173 |
fi |
170 |
|
174 |
|
171 |
local name="${0##*/}" |
175 |
local name="${0##*/}" |
Lines 187-193
Link Here
|
187 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
191 |
if ! yesno "${RC_ENDCOL}" && [ "${LAST_E_CMD}" = "ebegin" ]; then |
188 |
printf "\n" >&2 |
192 |
printf "\n" >&2 |
189 |
fi |
193 |
fi |
190 |
printf " ${BAD}*${NORMAL} ${RC_INDENTATION}$*\n" >&2 |
194 |
printf ' %b*%b %s%b\n' "${BAD}" "${NORMAL}" "${RC_INDENTATION}" "${*}" >&2 |
191 |
fi |
195 |
fi |
192 |
|
196 |
|
193 |
local name="${0##*/}" |
197 |
local name="${0##*/}" |
Lines 247-258
Link Here
|
247 |
fi |
251 |
fi |
248 |
|
252 |
|
249 |
if yesno "${RC_ENDCOL}"; then |
253 |
if yesno "${RC_ENDCOL}"; then |
250 |
printf "${ENDCOL} ${msg}\n" |
254 |
printf '%b %b\n' "${ENDCOL}" "${msg}" |
251 |
else |
255 |
else |
252 |
[ "${LAST_E_CMD}" = ebegin ] || LAST_E_LEN=0 |
256 |
[ "${LAST_E_CMD}" = ebegin ] || LAST_E_LEN=0 |
253 |
printf "%$(( COLS - LAST_E_LEN - 6 ))s%b\n" '' "${msg}" |
257 |
printf "%$(( COLS - LAST_E_LEN - 6 ))s%b\n" '' "${msg}" |
254 |
fi |
258 |
fi |
255 |
|
259 |
|
|
|
260 |
# shellcheck disable=SC2086 |
256 |
return ${retval} |
261 |
return ${retval} |
257 |
} |
262 |
} |
258 |
|
263 |
|
Lines 268-273
Link Here
|
268 |
_eend "${retval}" eerror "$*" |
273 |
_eend "${retval}" eerror "$*" |
269 |
|
274 |
|
270 |
LAST_E_CMD="eend" |
275 |
LAST_E_CMD="eend" |
|
|
276 |
# shellcheck disable=SC2086 |
271 |
return ${retval} |
277 |
return ${retval} |
272 |
} |
278 |
} |
273 |
|
279 |
|
Lines 283-288
Link Here
|
283 |
_eend "${retval}" ewarn "$*" |
289 |
_eend "${retval}" ewarn "$*" |
284 |
|
290 |
|
285 |
LAST_E_CMD="ewend" |
291 |
LAST_E_CMD="ewend" |
|
|
292 |
# shellcheck disable=SC2086 |
286 |
return ${retval} |
293 |
return ${retval} |
287 |
} |
294 |
} |
288 |
|
295 |
|
Lines 316-337
Link Here
|
316 |
veend() |
323 |
veend() |
317 |
{ |
324 |
{ |
318 |
yesno "${EINFO_VERBOSE}" && { eend "$@"; return $?; } |
325 |
yesno "${EINFO_VERBOSE}" && { eend "$@"; return $?; } |
|
|
326 |
# shellcheck disable=SC2086 |
319 |
return ${1:-0} |
327 |
return ${1:-0} |
320 |
} |
328 |
} |
321 |
|
329 |
|
322 |
vewend() |
330 |
vewend() |
323 |
{ |
331 |
{ |
324 |
yesno "${EINFO_VERBOSE}" && { ewend "$@"; return $?; } |
332 |
yesno "${EINFO_VERBOSE}" && { ewend "$@"; return $?; } |
|
|
333 |
# shellcheck disable=SC2086 |
325 |
return ${1:-0} |
334 |
return ${1:-0} |
326 |
} |
335 |
} |
327 |
|
336 |
|
328 |
veindent() |
337 |
veindent() |
329 |
{ |
338 |
{ |
|
|
339 |
# shellcheck disable=SC2119 |
330 |
yesno "${EINFO_VERBOSE}" && eindent |
340 |
yesno "${EINFO_VERBOSE}" && eindent |
331 |
} |
341 |
} |
332 |
|
342 |
|
333 |
veoutdent() |
343 |
veoutdent() |
334 |
{ |
344 |
{ |
|
|
345 |
# shellcheck disable=SC2119 |
335 |
yesno "${EINFO_VERBOSE}" && eoutdent |
346 |
yesno "${EINFO_VERBOSE}" && eoutdent |
336 |
} |
347 |
} |
337 |
|
348 |
|
Lines 345-351
Link Here
|
345 |
elif command -v portageq > /dev/null 2>&1; then |
356 |
elif command -v portageq > /dev/null 2>&1; then |
346 |
CONF_LIBDIR="$(portageq envvar CONF_LIBDIR)" |
357 |
CONF_LIBDIR="$(portageq envvar CONF_LIBDIR)" |
347 |
fi |
358 |
fi |
348 |
printf "${CONF_LIBDIR:=lib}\n" |
359 |
printf '%s\n' "${CONF_LIBDIR:=lib}" |
349 |
} |
360 |
} |
350 |
|
361 |
|
351 |
# |
362 |
# |
Lines 359-365
Link Here
|
359 |
|
370 |
|
360 |
[ ! -r /proc/cmdline ] && return 1 |
371 |
[ ! -r /proc/cmdline ] && return 1 |
361 |
|
372 |
|
362 |
read copts < /proc/cmdline |
373 |
read -r copts < /proc/cmdline |
363 |
for copt in $copts ; do |
374 |
for copt in $copts ; do |
364 |
if [ "${copt%=*}" = "gentoo" ] ; then |
375 |
if [ "${copt%=*}" = "gentoo" ] ; then |
365 |
params=$(gawk -v PARAMS="${copt##*=}" ' |
376 |
params=$(gawk -v PARAMS="${copt##*=}" ' |
Lines 379-384
Link Here
|
379 |
fi |
390 |
fi |
380 |
done |
391 |
done |
381 |
|
392 |
|
|
|
393 |
# shellcheck disable=SC2086 |
382 |
return ${retval} |
394 |
return ${retval} |
383 |
} |
395 |
} |
384 |
|
396 |
|
Lines 415-426
Link Here
|
415 |
# Default values for e-message indentation and dots |
427 |
# Default values for e-message indentation and dots |
416 |
RC_INDENTATION='' |
428 |
RC_INDENTATION='' |
417 |
RC_DEFAULT_INDENT=2 |
429 |
RC_DEFAULT_INDENT=2 |
|
|
430 |
# shellcheck disable=SC2034 |
418 |
RC_DOT_PATTERN='' |
431 |
RC_DOT_PATTERN='' |
419 |
|
432 |
|
420 |
# Cache the CONSOLETYPE - this is important as backgrounded shells don't |
433 |
# Cache the CONSOLETYPE - this is important as backgrounded shells don't |
421 |
# have a TTY. rc unsets it at the end of running so it shouldn't hang |
434 |
# have a TTY. rc unsets it at the end of running so it shouldn't hang |
422 |
# around |
435 |
# around |
423 |
if [ -z "${CONSOLETYPE}" ] ; then |
436 |
if [ -z "${CONSOLETYPE:-}" ] ; then |
424 |
CONSOLETYPE="$(consoletype stdout 2>/dev/null )"; export CONSOLETYPE |
437 |
CONSOLETYPE="$(consoletype stdout 2>/dev/null )"; export CONSOLETYPE |
425 |
fi |
438 |
fi |
426 |
if [ "${CONSOLETYPE}" = "serial" ] ; then |
439 |
if [ "${CONSOLETYPE}" = "serial" ] ; then |
Lines 439-446
Link Here
|
439 |
|
452 |
|
440 |
# Setup COLS and ENDCOL so eend can line up the [ ok ] |
453 |
# Setup COLS and ENDCOL so eend can line up the [ ok ] |
441 |
COLS="${COLUMNS:-0}" # bash's internal COLUMNS variable |
454 |
COLS="${COLUMNS:-0}" # bash's internal COLUMNS variable |
|
|
455 |
# shellcheck disable=SC2046 |
442 |
[ "$COLS" -eq 0 ] && \ |
456 |
[ "$COLS" -eq 0 ] && \ |
443 |
COLS="$(set -- $(stty size 2>/dev/null) ; printf "$2\n")" |
457 |
COLS="$(set -- $(stty size 2>/dev/null) ; printf '%s\n' "$2")" |
444 |
[ -z "$COLS" ] && COLS=80 |
458 |
[ -z "$COLS" ] && COLS=80 |
445 |
[ "$COLS" -gt 0 ] || COLS=80 # width of [ ok ] == 7 |
459 |
[ "$COLS" -gt 0 ] || COLS=80 # width of [ ok ] == 7 |
446 |
|
460 |
|
Lines 464-469
Link Here
|
464 |
GOOD=$(printf '\033[32;01m') |
478 |
GOOD=$(printf '\033[32;01m') |
465 |
WARN=$(printf '\033[33;01m') |
479 |
WARN=$(printf '\033[33;01m') |
466 |
BAD=$(printf '\033[31;01m') |
480 |
BAD=$(printf '\033[31;01m') |
|
|
481 |
# shellcheck disable=SC2034 |
467 |
HILITE=$(printf '\033[36;01m') |
482 |
HILITE=$(printf '\033[36;01m') |
468 |
BRACKET=$(printf '\033[34;01m') |
483 |
BRACKET=$(printf '\033[34;01m') |
469 |
NORMAL=$(printf '\033[0m') |
484 |
NORMAL=$(printf '\033[0m') |