]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1574] shell scripts: convert redirection to pipe
authorAndrei Pavel <andrei@isc.org>
Fri, 11 Dec 2020 11:53:01 +0000 (13:53 +0200)
committerAndrei Pavel <andrei@isc.org>
Mon, 14 Dec 2020 10:08:11 +0000 (12:08 +0200)
src/bin/admin/kea-admin.in
src/share/database/scripts/mysql/upgrade_8.1_to_8.2.sh.in

index 0e01ea0519acffea0c035f2387ad8e0b5d3d9214..1f9780193419465c6c4a5f9a5cbd0f4c7c3f159c 100644 (file)
@@ -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 "<empty>" <<<"${OUTPUT}")" -gt 0; then
+    if test "$(printf '%s' "${OUTPUT}" | grep -c '<empty>')" -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
index 1cc8046e76e4eb994f6918e1920bd537f54868c2..7b20c671b16ceef1e00cef51c367b23250922606 100644 (file)
@@ -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