From 31def99394abbdd05e27c7b92f004f736af38123 Mon Sep 17 00:00:00 2001 From: Michael Schnerring <3743342+schnerring@users.noreply.github.com> Date: Wed, 9 Sep 2020 19:14:16 +0200 Subject: [PATCH] fix grep redirection fix grep regexes --- disk-burnin.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/disk-burnin.sh b/disk-burnin.sh index 655595d..68f579a 100755 --- a/disk-burnin.sh +++ b/disk-burnin.sh @@ -225,7 +225,7 @@ fi # Check required dependencies readonly DEPENDENCIES="awk badblocks grep sed sleep" for dependency in ${DEPENDENCIES}; do - if ! command -v "${dependency}" > /dev/null 2>&1 ; then + if ! command -v "${dependency}" > /dev/null 2>&1; then echo "Command '${dependency}' not found" >&2 exit 2 fi @@ -244,7 +244,7 @@ fi # Drive to burn-in DRIVE="$1" # prepend /dev/ if necessary -if ! printf '%s' "${DRIVE}" | grep "/dev/*" > /dev/null 2>&1; then +if ! printf '%s' "${DRIVE}" | grep "/dev/\w*" > /dev/null 2>&1; then DRIVE="/dev/${DRIVE}" fi readonly DRIVE @@ -483,13 +483,15 @@ poll_selftest_complete() { l_poll_duration_seconds=0 while [ "${l_poll_duration_seconds}" -lt "${POLL_TIMEOUT_SECONDS}" ]; do - smartctl --all "${DRIVE}" | grep -i "The previous self-test routine completed" > /dev/null 2<&1 + smartctl --all "${DRIVE}" \ + | grep -i "The previous self-test routine completed" > /dev/null 2>&1 l_status="$?" if [ "${l_status}" -eq 0 ]; then log_info "SMART self-test succeeded" return 0 fi - smartctl --all "${DRIVE}" | grep -i "of the test failed." > /dev/null 2<&1 + smartctl --all "${DRIVE}" \ + | grep -i "of the test failed\." > /dev/null 2>&1 l_status="$?" if [ "${l_status}" -eq 0 ]; then log_info "SMART self-test failed"