diff options
-rwxr-xr-x | otp.bash | 2 | ||||
-rwxr-xr-x | test/append.t | 10 |
2 files changed, 11 insertions, 1 deletions
@@ -268,7 +268,7 @@ cmd_otp_append() { [[ -f $passfile ]] || die "Passfile not found" local existing contents="" - while IFS= read -r line; do + while IFS= read -r line || [ -n "$line" ]; do [[ -z "$existing" && "$line" == otpauth://* ]] && existing="$line" [[ -n "$contents" ]] && contents+=$'\n' contents+="$line" diff --git a/test/append.t b/test/append.t index 7f6d0af..a773e62 100755 --- a/test/append.t +++ b/test/append.t @@ -133,4 +133,14 @@ EOF [[ $("$PASS" show passfile) == "$expected" ]] ' +test_expect_success 'Keep original password' ' + existing="foo bar baz" + uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Foo" + + test_pass_init && + "$PASS" insert -e passfile <<< "$existing" && + "$PASS" otp append -e passfile <<< "$uri" && + [[ $("$PASS" show passfile | head -1) == "$existing" ]] +' + test_done |