summaryrefslogtreecommitdiff
path: root/tests/fake-editor-change-password.sh
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2014-04-22 18:35:11 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2014-04-22 18:35:11 +0200
commit760c644a1d9f55c91b74521b112958966e00ea31 (patch)
tree2514b500511a8dcf0d56d2a49ee69487f5cb4f56 /tests/fake-editor-change-password.sh
parent07bcfccebfa2f885849f0b8698a496c3c757d8a7 (diff)
downloadpass-760c644a1d9f55c91b74521b112958966e00ea31.tar.gz
pass-760c644a1d9f55c91b74521b112958966e00ea31.tar.bz2
pass-760c644a1d9f55c91b74521b112958966e00ea31.zip
Import Von's tests, with cleanups.
Diffstat (limited to 'tests/fake-editor-change-password.sh')
-rwxr-xr-xtests/fake-editor-change-password.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/fake-editor-change-password.sh b/tests/fake-editor-change-password.sh
new file mode 100755
index 0000000..bfae8e1
--- /dev/null
+++ b/tests/fake-editor-change-password.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Fake editor program for testing 'pass edit'.
+# Changes password to 'Hello World', leaving rest of file intact.
+#
+# Intended use:
+# export FAKE_EDITOR_PASSWORD="blah blah blah"
+# export EDITOR=fake-editor-change-password.sh
+# $EDITOR <password file>
+#
+# Arguments: <filename>
+# Returns: 0 on success, 1 on error
+
+if [[ $# -ne 1 ]]; then
+ echo "Usage: $0 <filename>"
+ exit 1
+fi
+
+filename=$1 ; shift ;
+new_password="${FAKE_EDITOR_PASSWORD:-Hello World}"
+
+# And change only first line of file
+# -i.tmp allows editing file in place. Extension needed on Mac OSX
+sed -i.tmp "1 s/^.*$/$new_password/g" "$filename"
+
+exit 0
ecoro2-10/+10 2008-01-14 r609@Devoty: necoro | 2008-01-14 17:04:38 +0100Necoro9-394/+477 2008-01-14 r605@Devoty: necoro | 2008-01-14 11:43:34 +0100Necoro2-26/+129 2008-01-14 r603@Devoty: necoro | 2008-01-14 11:30:26 +0100Necoro4-26/+38 2008-01-11 r598@Devoty: necoro | 2008-01-10 16:36:29 +0100Necoro4-10/+50 2008-01-11 r597@Devoty: necoro | 2008-01-10 14:12:35 +0100Necoro1-3/+3 2008-01-10 r595@Devoty: necoro | 2008-01-10 04:04:15 +0100Necoro1-52/+3 2008-01-09 r586@Devoty: necoro | 2008-01-09 14:54:18 +0100Necoro1-1/+1 2007-12-06 r577@Devoty: necoro | 2007-12-06 20:37:36 +0100Necoro1-1/+1 2007-12-06 r572@Devoty: necoro | 2007-11-28 08:48:15 +0100Necoro1-0/+1 2007-11-27 r570@Devoty: necoro | 2007-11-27 02:08:21 +0100Necoro3-84/+108