diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2014-04-22 18:35:11 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2014-04-22 18:35:11 +0200 |
commit | 760c644a1d9f55c91b74521b112958966e00ea31 (patch) | |
tree | 2514b500511a8dcf0d56d2a49ee69487f5cb4f56 /tests/fake-editor-change-password.sh | |
parent | 07bcfccebfa2f885849f0b8698a496c3c757d8a7 (diff) | |
download | pass-760c644a1d9f55c91b74521b112958966e00ea31.tar.gz pass-760c644a1d9f55c91b74521b112958966e00ea31.tar.bz2 pass-760c644a1d9f55c91b74521b112958966e00ea31.zip |
Import Von's tests, with cleanups.
Diffstat (limited to '')
-rwxr-xr-x | tests/fake-editor-change-password.sh | 25 |
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 |