diff --git a/notwa-util/Dockerfile b/notwa-util/Dockerfile index f06a6ea..a66b469 100644 --- a/notwa-util/Dockerfile +++ b/notwa-util/Dockerfile @@ -3,7 +3,7 @@ FROM alpine:3.16 as partial # need this for acquire (.tar.xz files): RUN apk add --no-cache xz -COPY --chmod=0755 acquire cosmocc dedupe quickconf \ +COPY --chmod=0755 acquire cosmocc dedupe quickconf shed \ /usr/local/bin/ FROM partial as downloader diff --git a/notwa-util/shed b/notwa-util/shed new file mode 100644 index 0000000..2dd1f05 --- /dev/null +++ b/notwa-util/shed @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +: \ + && f="${1?missing filename}" && shift \ + && for e in "$@" \ + ;do : \ + && cp "$f" "$f.bak" && sed -i -e "$e" "$f" \ + && { diff -q "$f" "$f.bak" >/dev/null; [ $? = 1 ] ;} \ + || { printf >&2 '\033[91mfailed to apply sed:\033[m\n%s\n' "$e"; exit 1 ;} \ + && rm "$f.bak" || exit \ + ;done \ +;