Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "WITH-EDITOR:: -c: line 0: unexpected EOF while looking for matching `'' #40

Closed
svend opened this issue Oct 12, 2017 · 11 comments
Closed
Assignees

Comments

@svend
Copy link

svend commented Oct 12, 2017

I'm getting the following error in the *Async Shell Command* buffer with version ee39f23 of with-editor when runing (with-editor-async-shell-command "pass edit foobar") . (pass command is from https://www.passwordstore.org/).

"WITH-EDITOR:: -c: line 0: unexpected EOF while looking for matching `''
"WITH-EDITOR:: -c: line 1: syntax error: unexpected end of file
Password unchanged.

The following also appears in the *Messages* buffer.

#<process Shell>
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\' pass edit foobar: exited abnormally with code 1.

If I checkout the commit before 99d3278, the same command works.

I am running GNU Emacs 26.0.60 on macOS.

@tarsius
Copy link
Member

tarsius commented Oct 12, 2017

Just in case, try with crontab -e instead of pass edit foobar.

@svend
Copy link
Author

svend commented Oct 13, 2017

crontab -e works. I'll try to figure out what is different with pass.

@myrjola
Copy link

myrjola commented Oct 14, 2017

I have the same issue. I didn't figure out the root cause. The with-editor package has worked before with password-store.el. However, now there may be some kind of quotation issue. As a workaround I downgraded password-store.el to the commit before the with-editor support. Specifically, I reverted to commit 38ec1c72e29c872ec0cdde82f75490640d4019bf.

@DamienCassou
Copy link

I have exactly the same problem.

@tarsius
Copy link
Member

tarsius commented Oct 20, 2017

I believe that with-editor isn't the cause here but that various tools that use $EDITOR fail if they encounter quotes in the value of that variable. systemctl seems to be another.

@DamienCassou
Copy link

The issue arrived with with-editor commit 99d3278. You can reproduce with this script in /tmp/pass

#!/usr/bin/env bash

${EDITOR} /home/cassou/.bashrc

and this form: (with-editor-async-shell-command "/tmp/pass").

@tarsius
Copy link
Member

tarsius commented Oct 20, 2017

You can reproduce with this script

You have to use:

#!/usr/bin/env bash

eval "${EDITOR}" /home/cassou/.bashrc

The issue arrived with with-editor commit 99d3278.

This commit didn't break anything by itself but because it removes a code-path that was previously used in most cases it causes another code-path to be used - and that exhibits this issue. But as I said, I believe the issue is that - like your script - many tools do not properly deal with spaces and/or quotes in $EDITOR.

@DamienCassou
Copy link

Is there any workaround we could have in with-editor or do we have to patch all shell scripts we want to use with with-editor?

@tarsius
Copy link
Member

tarsius commented Oct 22, 2017

I could revert 99d3278 or add an option so that users could choose the defect that bothers them less. It would be best though if emacsclient were modified to pass along the environment in all cases.

@svend
Copy link
Author

svend commented Oct 22, 2017

I've submitted a patch for password-store to use eval.

@tarsius tarsius self-assigned this Nov 27, 2017
tarsius added a commit that referenced this issue Nov 27, 2017
This fixes the issues described in #40 and reintroduces the issue
described in #23.  Users who do not care about #40 but don't like #23
can set the new option `with-editor-shell-command-use-emacsclient' to
nil.
@tarsius
Copy link
Member

tarsius commented Nov 27, 2017

I have reverted the fix for #23, thus fixing the issue brought up here. I have also added an option for users who don't care about these issues, but don't like #23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants