[m-rev.] diff: do not hardcode sed in the bootcheck script

Julien Fischer jfischer at opturion.com
Fri Dec 30 17:07:43 AEDT 2022


Do not hardcode sed in the bootcheck script.

tools/bootcheck:
     Allow the executable name used for sed to be overridden
     in the environment. (This is useful for using the GNU
     version of sed on macOS instead of the one it ships with.)

Julien.

diff --git a/tools/bootcheck b/tools/bootcheck
index 6028f2d..e41b8e9 100755
--- a/tools/bootcheck
+++ b/tools/bootcheck
@@ -637,13 +637,17 @@ fi

  #-----------------------------------------------------------------------------#

+SED=${SED:-sed}
+
+#-----------------------------------------------------------------------------#
+
  # Turn off the debugger, since accidentally leaving it on will result
  # in user interaction every time we invoke any version of the compiler
  # that was compiled with tracing. This has happened to me accidentally
  # one too many times - zs.
  if echo "${MERCURY_OPTIONS}" | grep '\-Di' > /dev/null
  then
-    MERCURY_OPTIONS=$(echo "${MERCURY_OPTIONS}" | sed -e 's/-Di//')
+    MERCURY_OPTIONS=$(echo "${MERCURY_OPTIONS}" | $SED -e 's/-Di//')
      export MERCURY_OPTIONS
  fi

@@ -2056,11 +2060,11 @@ then

          cp "${root}"/doc/mdb_command_test.inp tests/debugger

-        sed -e "s:@WORKSPACE@:${WORKSPACE}:" \
+        ${SED} -e "s:@WORKSPACE@:${WORKSPACE}:" \
              < tests/WS_FLAGS.ws \
              > tests/WS_FLAGS

-        sed -e "s:@WORKSPACE@:${WORKSPACE}:" \
+        ${SED} -e "s:@WORKSPACE@:${WORKSPACE}:" \
              < tests/.mgnuc_copts.ws \
              > tests/.mgnuc_copts

@@ -2320,7 +2324,7 @@ cat /dev/null > "${tests_dir}"/EXPECT_FAIL_TESTS

  if test -s "${tests_dir}"/FAILED_TESTS_SUMMARY
  then
-    sed -e 's/ .*//' < "${tests_dir}"/FAILED_TESTS_SUMMARY \
+    ${SED} -e 's/ .*//' < "${tests_dir}"/FAILED_TESTS_SUMMARY \
          > "${tests_dir}"/FAIL_TESTS

      if test -f "${tests_dir}"/EXPECT_FAIL_TESTS.all_grades
@@ -2414,13 +2418,13 @@ then
          1)
              echo "one expected test case failure:"
              echo
-            sed -e 's/^/    /' < "${tests_dir}"/EXPECTED_FAILED_TESTS
+            ${SED} -e 's/^/    /' < "${tests_dir}"/EXPECTED_FAILED_TESTS
              echo
              ;;
          *)
              echo "${num_expected_failures} expected test case failures:"
              echo
-            sed -e 's/^/    /' < "${tests_dir}"/EXPECTED_FAILED_TESTS
+            ${SED} -e 's/^/    /' < "${tests_dir}"/EXPECTED_FAILED_TESTS
              echo
              ;;
      esac
@@ -2432,13 +2436,13 @@ then
          1)
              echo "one unexpected test case failure:"
              echo
-            sed -e 's/^/    /' < "${tests_dir}"/UNEXPECTED_FAILED_TESTS
+            ${SED} -e 's/^/    /' < "${tests_dir}"/UNEXPECTED_FAILED_TESTS
              echo
              ;;
          *)
              echo "${num_unexpected_failures} unexpected test case failures:"
              echo
-            sed -e 's/^/    /' < "${tests_dir}"/UNEXPECTED_FAILED_TESTS
+            ${SED} -e 's/^/    /' < "${tests_dir}"/UNEXPECTED_FAILED_TESTS
              echo
              ;;
      esac


More information about the reviews mailing list