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

added support for $EDITOR not being an executable #227

Merged
merged 8 commits into from
Jun 13, 2020

Conversation

venus-as-a-boy
Copy link
Contributor

it's kind of a hack, but in order to well support whatever they have as their $EDITOR you'll need to interpret shell faithfully, so it has to be a bit hacky. I wanted to use sh, but sh doesn't have the -c option (I don't think it's posix). I suppose this could be improved by checking the shell environment variable and acting accordingly, but supporting shells that don't have the "-c" option seems impossible. I figured trying to support all shells was futile so I just passed it to bash because that covers 99.9% of cases. (if your $EDITOR is not bash compliant I'm curious what black magic you are doing)

-- Show it first in case the editor launch fails
showAction path
executeFile editorExe True [path] Nothing
executeFile "bash" True ["-c", editor ++ ' ' : path ] Nothing
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this break if path had whitespace in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does path not create escape characters? How was it working before?

Copy link
Owner

@srid srid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: I tested this with EDITOR=vim and it simply hangs.

@@ -45,11 +44,11 @@ newZettelFile NewCommand {..} = do
case mzid of
Left e -> die $ show e
Right zid -> do
path <- zettelPath zid
(notesDir, filename) <- zettelPath zid
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get rid of the zettelPath function, and inline its body here.

@srid srid merged commit 09e6cf5 into srid:master Jun 13, 2020
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

Successfully merging this pull request may close these issues.

2 participants