add shed
utility to apply sed more intelligently
This commit is contained in:
parent
c3eb9c90ca
commit
39dc4acfca
2 changed files with 12 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
||||||
FROM alpine:3.16 as partial
|
FROM alpine:3.16 as partial
|
||||||
# need this for acquire (.tar.xz files):
|
# need this for acquire (.tar.xz files):
|
||||||
RUN apk add --no-cache xz
|
RUN apk add --no-cache xz
|
||||||
COPY --chmod=0755 acquire cosmocc dedupe quickconf \
|
COPY --chmod=0755 acquire cosmocc dedupe quickconf shed \
|
||||||
/usr/local/bin/
|
/usr/local/bin/
|
||||||
|
|
||||||
FROM partial as downloader
|
FROM partial as downloader
|
||||||
|
|
11
notwa-util/shed
Normal file
11
notwa-util/shed
Normal file
|
@ -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 \
|
||||||
|
;
|
Loading…
Add table
Reference in a new issue