From 10faf4ad2fe9a81b036c1aca24efec964c825393 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 22 Jun 2022 10:48:37 +0300 Subject: sq: make use of sed in subplot more portable Sponsored-by: pep.foundation --- sq/sq-subplot.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'sq') diff --git a/sq/sq-subplot.md b/sq/sq-subplot.md index e1d6908c..269716f4 100644 --- a/sq/sq-subplot.md +++ b/sq/sq-subplot.md @@ -1154,14 +1154,25 @@ the file by definition can't be valid anymore. ~~~scenario given an installed sq given file hello.txt +given file sed-in-place when I run sq key generate --export key.pgp when I run sq key extract-cert key.pgp -o cert.pgp when I run sq sign --signer-key key.pgp hello.txt -o signed.txt -when I run sed -i 3d signed.txt +when I run bash sed-in-place 3d signed.txt when I try to run sq verify --signer-cert cert.pgp signed.txt then command fails ~~~ +~~~{#sed-in-place .file .sh} +#!/bin/sh + +set -eu +tmp="$(mktemp)" +trap 'rm -f "$tmp"' EXIT +sed "$1" "$2" > "$tmp" +cat "$tmp" > "$2" +~~~ + ## Create cleartext signature _Requirement: We can create a signature such that the signed data is @@ -1190,11 +1201,12 @@ verified._ ~~~scenario given an installed sq given file hello.txt +given file sed-in-place when I run sq key generate --export key.pgp when I run sq key extract-cert key.pgp -o cert.pgp when I run sq sign --cleartext-signature --signer-key key.pgp hello.txt -o signed.txt -when I run sed -i s/hello/HELLO/ signed.txt +when I run bash sed-in-place s/hello/HELLO/ signed.txt when I try to run sq verify --signer-cert cert.pgp signed.txt then exit code is 1 ~~~ @@ -1227,11 +1239,12 @@ modified, the signature can't be verified._ ~~~scenario given an installed sq given file hello.txt +given file sed-in-place when I run sq key generate --export key.pgp when I run sq key extract-cert key.pgp -o cert.pgp when I run sq sign --detached --signer-key key.pgp hello.txt -o sig.txt -when I run sed -i s/hello/HELLO/ hello.txt +when I run bash sed-in-place s/hello/HELLO/ hello.txt when I try to run sq verify --detached=sig.txt --signer-cert=cert.pgp hello.txt then exit code is 1 ~~~ -- cgit v1.2.3