From 2990bd053813a13d736a13a42f6eb029e9dc9575 Mon Sep 17 00:00:00 2001 From: Chris Holland Date: Sat, 20 Jan 2024 14:35:10 -0800 Subject: [PATCH] add sed -i lint check to ensure portability --- ci/lint.sh | 5 +++++ scripts/changelog_mangler.sh | 2 +- scripts/make_tutorial.sh | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ci/lint.sh b/ci/lint.sh index d07a94ce..bd3d76e7 100755 --- a/ci/lint.sh +++ b/ci/lint.sh @@ -5,5 +5,10 @@ if [ -x "$(command -v shellcheck)" ]; then else echo "Warning: shellcheck is not installed, skipping shell scripts" fi +incompatible_sed=$(! grep -RPn --color=always --exclude-dir=node_modules --exclude-dir=.git 'sed(?:\s-\w+)*\s-i(?!\S|\s"")') +if [ "$incompatible_sed" ]; then + printf "\nWarning: avoid non-portable sed flag -i without backup extension, use -i.bak\n" + printf "%s\n\n" "$incompatible_sed" +fi yarn run lint "$(yarn bin)/eslint" --rulesdir custom-eslint-rules --ext .ts . diff --git a/scripts/changelog_mangler.sh b/scripts/changelog_mangler.sh index 9693922d..48fe4b21 100755 --- a/scripts/changelog_mangler.sh +++ b/scripts/changelog_mangler.sh @@ -1,4 +1,4 @@ #!/bin/sh # Replace issue numbers in brackets eg (#1337) with a link to the issue on the repository -sed -i 's; (#\([0-9]*\)); ([#\1](https://github.com/tridactyl/tridactyl/issues/\1));g' CHANGELOG.md +sed -i.bak 's; (#\([0-9]*\)); ([#\1](https://github.com/tridactyl/tridactyl/issues/\1));g' CHANGELOG.md diff --git a/scripts/make_tutorial.sh b/scripts/make_tutorial.sh index af7c630f..fb008fe4 100755 --- a/scripts/make_tutorial.sh +++ b/scripts/make_tutorial.sh @@ -16,5 +16,5 @@ do sed "/REPLACETHIS/,$ d" tutor.template.html > "$dest$fileroot.html" "$(yarn bin)/marked" "$page" >> "$dest$fileroot.html" sed "1,/REPLACETHIS/ d" tutor.template.html >> "$dest$fileroot.html" - sed -i "s|\.md|.html|g" "$dest$fileroot.html" + sed -i.bak "s|\.md|.html|g" "$dest$fileroot.html" done