From bd3a6bbf8e527436eb549b60fc437f224740778b Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Sat, 11 Oct 2025 21:23:34 +0200 Subject: [PATCH] [type/__sed] Fix for NetBSD (-f -) NetBSD sed(1) does not accept -f - to read the script from stdin: sed: -: No such file or directory Since the script has to be copied to code-remote anyway (for the `--script -` case), instead of putting it into a here-document we can pass it into sed -e instead. I decided to go with multiple -e options (one per line), but passing the whole script into a single -e should work as well. --- type/__sed/gencode-remote | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/type/__sed/gencode-remote b/type/__sed/gencode-remote index 86e86c01c..51b735fce 100755 --- a/type/__sed/gencode-remote +++ b/type/__sed/gencode-remote @@ -19,6 +19,12 @@ # along with skonfig-base. If not, see . # +shquot() { + sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" <<-EOF + $* + EOF +} + if [ -f "${__object:?}/parameter/file" ] then file=$(cat "${__object:?}/parameter/file") @@ -58,11 +64,12 @@ fi # shellcheck disable=SC2016 echo 'tmp="${__object:?}/tempfile"' -echo "${sed_cmd} -f - '${file}' >\"\${tmp}\" <<'EOF'" -cat "${script_file}" -echo 'EOF' +printf '%s \\\n' "${sed_cmd}" +sed -e "s/'/'\\\\''/g" -e "s/^.*$/ -e '&' \\\\/" "${script_file}" +# shellcheck disable=SC2016 +printf '%s >%s\n' "$(shquot "${file}")" '"${tmp}"' -echo "cp \"\${tmp}\" '${file}'" +echo "cp \"\${tmp}\" $(shquot "${file}")" # shellcheck disable=SC2016 echo 'rm -f "${tmp}"'