From 760c644a1d9f55c91b74521b112958966e00ea31 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 22 Apr 2014 18:35:11 +0200 Subject: Import Von's tests, with cleanups. --- tests/fake-editor-change-password.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 tests/fake-editor-change-password.sh (limited to 'tests/fake-editor-change-password.sh') 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 +# +# Arguments: +# Returns: 0 on success, 1 on error + +if [[ $# -ne 1 ]]; then + echo "Usage: $0 " + 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 -- cgit v1.2.3