[PATCH] Call EDITOR using eval

Svend Sorensen svend at svends.net
Sun Oct 22 19:32:24 CEST 2017


This fixes an issue where the EDITOR variable contains quotes. The Emacs
with-editor package sets EDITOR to the following.

```
EDITOR=sh\ -c\ \'echo\ \"WITH-EDITOR\:\ \$\$\ OPEN\ \$0\"\;\ sleep\ 604800\ \&\ sleep\=\$\!\;\ trap\ \"kill\ \$sleep\;\ exit\ 0\"\ USR1\;\ trap\ \"kill\ \$sleep\;\ exit\ 1\"\ USR2\;\ wait\ \$sleep\'
```

When this is used without eval, it fails with a syntax error.

```
$ $EDITOR pass edit my-entry
"WITH-EDITOR:: -c: line 0: unexpected EOF while looking for matching `''
"WITH-EDITOR:: -c: line 1: syntax error: unexpected end of file
```

It works when called using eval.

```
$ eval "$EDITOR" pass edit my-entry
```

This was discussed on the Emacs with-editor bug tracker here:

https://github.com/magit/with-editor/issues/40
---
 src/password-store.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git src/password-store.sh src/password-store.sh
index b86631d..12c979b 100755
--- src/password-store.sh
+++ src/password-store.sh
@@ -478,7 +478,7 @@ cmd_edit() {
 		$GPG -d -o "$tmp_file" "${GPG_OPTS[@]}" "$passfile" || exit 1
 		action="Edit"
 	fi
-	${EDITOR:-vi} "$tmp_file"
+	eval "${EDITOR:-vi}" "$tmp_file"
 	[[ -f $tmp_file ]] || die "New password not saved."
 	$GPG -d -o - "${GPG_OPTS[@]}" "$passfile" 2>/dev/null | diff - "$tmp_file" &>/dev/null && die "Password unchanged."
 	while ! $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile" "${GPG_OPTS[@]}" "$tmp_file"; do
-- 
2.14.2



More information about the Password-Store mailing list