From: Andrei Pavel Date: Fri, 11 Dec 2020 11:53:01 +0000 (+0200) Subject: [#1574] shell scripts: convert redirection to pipe X-Git-Tag: Kea-1.9.3~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=232fc97021d6c2cbfc0aaca469c79f07951482f7;p=thirdparty%2Fkea.git [#1574] shell scripts: convert redirection to pipe --- diff --git a/src/bin/admin/kea-admin.in b/src/bin/admin/kea-admin.in index 0e01ea0519..1f97801934 100644 --- a/src/bin/admin/kea-admin.in +++ b/src/bin/admin/kea-admin.in @@ -220,7 +220,6 @@ mysql_init() { # mysql may spit out connection or access errors to stderr, we ignore those. # We should not hide them as they may give hints to user what is wrong with # his setup. - # run_and_return_output_and_exit_code \ mysql_execute "SHOW TABLES;" if [ "${EXIT_CODE}" -ne 0 ] @@ -229,7 +228,7 @@ mysql_init() { exit 1 fi - count=$(wc -w <<<"${OUTPUT}") + count=$(printf '%s' "${OUTPUT}" | wc -w) if [ "${count}" -gt 0 ]; then # Let's start with a new line. mysql could have printed something out. printf '\n' @@ -270,8 +269,9 @@ pgsql_init() { exit 1 fi - count=$(wc -w <<<"${OUTPUT}") + count=$(printf '%s' "${OUTPUT}" | wc -w) if [ "${count}" -gt 0 ]; then + # Let's start with a new line. pgsql could have printed something out. printf '\n' log_error "Expected empty database ${db_name}. Aborting, the following tables are present: ${OUTPUT}" @@ -301,7 +301,7 @@ cql_init() { # Shellcheck complaints about missing quotes and word splitting here. There # is no problem here as wc -w always returns a single number. # shellcheck disable=SC2046 - if test "$(grep -c "" <<<"${OUTPUT}")" -gt 0; then + if test "$(printf '%s' "${OUTPUT}" | grep -c '')" -gt 0; then printf 'Creating and initializing tables using script %s...\n' "${scripts_dir}/cql/dhcpdb_create.cql" cql_execute_script "${scripts_dir}/cql/dhcpdb_create.cql" else diff --git a/src/share/database/scripts/mysql/upgrade_8.1_to_8.2.sh.in b/src/share/database/scripts/mysql/upgrade_8.1_to_8.2.sh.in index 1cc8046e76..7b20c671b1 100644 --- a/src/share/database/scripts/mysql/upgrade_8.1_to_8.2.sh.in +++ b/src/share/database/scripts/mysql/upgrade_8.1_to_8.2.sh.in @@ -40,7 +40,7 @@ fi # query information_schema for the right database. for arg in "${@}" do - if ! grep -Eq '^\-\-' <<<"${arg}" + if ! printf '%s' "${arg}" | grep -Eq '^\-\-' then schema="$arg" break