Skip to content

Commit be08c12

Browse files
authored
fix(shell): SC2230/avoid nonstandard which command (#457)
* fix(shell): SC2230 avoid `which` * fix(shell): remove empty strings after echo * fix(shell): `then` on same line as `if`
1 parent 1df4495 commit be08c12

File tree

11 files changed

+221
-282
lines changed

11 files changed

+221
-282
lines changed

docker/mysql-xtrabackup/xbackup.sh

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,9 @@ _s_inf "INFO: Backup job started: ${_start_backup_date}"
442442
DEFAULTS_FILE_FLAG=
443443
[ -n "${DEFAULTS_FILE}" ] && DEFAULTS_FILE_FLAG="--defaults-file=${DEFAULTS_FILE}"
444444
# Check for innobackupex
445-
_ibx=$(which innobackupex)
446-
if [ "$?" -gt 0 ]; then _d_inf "ERROR: Could not find innobackupex binary!"; fi
445+
if ! _ibx=$(command -v innobackupex); then
446+
_d_inf 'ERROR: Could not find innobackupex binary!'
447+
fi
447448
if [ -n ${DEFAULTS_FILE} ]; then _ibx="${_ibx} ${DEFAULTS_FILE_FLAG}"; fi
448449
if [ "x${GALERA_INFO}" = "x1" ]; then _ibx="${_ibx} --galera-info"; fi
449450

@@ -463,12 +464,9 @@ fi
463464
#
464465
# Determine what will be our --incremental-basedir
465466
#
466-
if [ "${BKP_TYPE}" = "incr" ];
467-
then
468-
if [ -n "${INC_BSEDIR}" ];
469-
then
470-
if [ ! -d ${WORK_DIR}/bkps/${INC_BSEDIR} ];
471-
then
467+
if [ "${BKP_TYPE}" = "incr" ]; then
468+
if [ -n "${INC_BSEDIR}" ]; then
469+
if [ ! -d ${WORK_DIR}/bkps/${INC_BSEDIR} ]; then
472470
_d_inf "ERROR: Specified incremental basedir ${WORK_DIR}/bkps/${_inc_basedir} does not exist.";
473471
fi
474472

@@ -477,17 +475,15 @@ then
477475
_inc_basedir=${_last_bkp}
478476
fi
479477

480-
if [ ! -n "${_inc_basedir}" ];
481-
then
478+
if [ ! -n "${_inc_basedir}" ]; then
482479
_d_inf "ERROR: No valid incremental basedir found!";
483480
fi
484481

485482
( [ "x${APPLY_LOG}" = "x1" ] || [ "x${STOR_CMP}" = "x1" ] ) && \
486483
_inc_basedir_path="${WORK_DIR}/bkps/${_inc_basedir}" || \
487484
_inc_basedir_path="${STOR_DIR}/bkps/${_inc_basedir}"
488485

489-
if [ ! -d "${_inc_basedir_path}" ];
490-
then
486+
if [ ! -d "${_inc_basedir_path}" ]; then
491487
_d_inf "ERROR: Incremental basedir ${_inc_basedir_path} does not exist.";
492488
fi
493489

@@ -662,17 +658,14 @@ if [ "${status}" != 1 ]; then
662658
_start_prepare_date=$(date)
663659
_s_inf "INFO: Apply log started: ${_start_prepare_date}"
664660

665-
if [ "${BKP_TYPE}" = "incr" ];
666-
then
667-
if [ ! -n "${_incr_base}" ];
668-
then
661+
if [ "${BKP_TYPE}" = "incr" ]; then
662+
if [ ! -n "${_incr_base}" ]; then
669663
_d_inf "ERROR: No valid base backup found!";
670664
fi
671665

672666
_incr_base=P_${_incr_base}
673667

674-
if [ ! -d "${WORK_DIR}/bkps/${_incr_base}" ];
675-
then
668+
if [ ! -d "${WORK_DIR}/bkps/${_incr_base}" ]; then
676669
_d_inf "ERROR: Base backup ${WORK_DIR}/bkps/${_incr_base} does not exist.";
677670
fi
678671
_ibx_prep="${_ibx_prep} --apply-log --redo-only ${WORK_DIR}/bkps/${_incr_base} --incremental-dir ${_this_bkp}"

docker/openemr/7.0.3/openemr.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,16 +437,16 @@ fi
437437

438438
if [ "${SWARM_MODE}" = "yes" ]; then
439439
# Set flag that the instance is ready when in swarm mode
440-
echo ""
440+
echo
441441
echo "swarm mode on: this instance is ready"
442-
echo ""
442+
echo
443443
touch /root/instance-swarm-ready
444444
fi
445445

446-
echo ""
446+
echo
447447
echo "Love OpenEMR? You can now support the project via the open collective:"
448448
echo " > https://opencollective.com/openemr/donate"
449-
echo ""
449+
echo
450450

451451
if [ "${OPERATOR}" = yes ]; then
452452
echo 'Starting apache!'

docker/openemr/7.0.4/openemr.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,16 +437,16 @@ fi
437437

438438
if [ "${SWARM_MODE}" = "yes" ]; then
439439
# Set flag that the instance is ready when in swarm mode
440-
echo ""
440+
echo
441441
echo "swarm mode on: this instance is ready"
442-
echo ""
442+
echo
443443
touch /root/instance-swarm-ready
444444
fi
445445

446-
echo ""
446+
echo
447447
echo "Love OpenEMR? You can now support the project via the open collective:"
448448
echo " > https://opencollective.com/openemr/donate"
449-
echo ""
449+
echo
450450

451451
if [ "${OPERATOR}" = yes ]; then
452452
echo 'Starting apache!'

docker/openemr/flex-3.20/openemr.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,10 @@ else
505505
fi
506506
fi
507507

508-
echo ""
508+
echo
509509
echo "Love OpenEMR? You can now support the project via the open collective:"
510510
echo " > https://opencollective.com/openemr/donate"
511-
echo ""
511+
echo
512512

513513
if [ "${OPERATOR}" = yes ]; then
514514
echo 'Starting apache!'

docker/openemr/flex-3.21/openemr.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,10 @@ else
505505
fi
506506
fi
507507

508-
echo ""
508+
echo
509509
echo "Love OpenEMR? You can now support the project via the open collective:"
510510
echo " > https://opencollective.com/openemr/donate"
511-
echo ""
511+
echo
512512

513513
if [ "${OPERATOR}" = yes ]; then
514514
echo 'Starting apache!'

docker/openemr/flex-edge/openemr.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,10 @@ else
515515
fi
516516
fi
517517

518-
echo ""
518+
echo
519519
echo "Love OpenEMR? You can now support the project via the open collective:"
520520
echo " > https://opencollective.com/openemr/donate"
521-
echo ""
521+
echo
522522

523523
if [ "${OPERATOR}" = yes ]; then
524524
echo 'Starting apache!'

utilities/openemr-cmd/openemr-cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ fi
353353

354354
# Script usage.
355355
if [[ $# -eq 0 || "${FIRST_ARG}" = '--help' || "${FIRST_ARG}" = '-h' ]]; then
356-
echo ""
356+
echo
357357
echo "Usage: ${0##*/} COMMAND [ARGS]"
358358
echo "Usage: ${0##*/} -d <docker name> COMMAND [ARGS]"
359359
echo "Options:"

utilities/openemr-cmd/openemr-cmd-h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ filter_help_output(){
1212
}
1313

1414
# Use (( )) for numeric comparisons
15-
if (( $# == 0 ))
16-
then
15+
if (( $# == 0 )); then
1716
echo "To search the keyword from openemr-cmd -h output quickly
1817
Usage: openemr-cmd-h keyword
1918
e.g. openemr-cmd-h ssl

0 commit comments

Comments
 (0)