summaryrefslogtreecommitdiffstats
path: root/sq
diff options
context:
space:
mode:
authorLars Wirzenius <liw@sequoia-pgp.org>2022-06-22 10:48:37 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2022-06-22 10:48:37 +0300
commit10faf4ad2fe9a81b036c1aca24efec964c825393 (patch)
treef863fbb3a2bb6d9abe171ca294ef1efd88a7df92 /sq
parent0dc5553b9bee470cc88b436a949b596786b675e4 (diff)
sq: make use of sed in subplot more portable
Sponsored-by: pep.foundation
Diffstat (limited to 'sq')
-rw-r--r--sq/sq-subplot.md19
1 files changed, 16 insertions, 3 deletions
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
~~~