Giter VIP home page Giter VIP logo

Comments (4)

tarsius avatar tarsius commented on September 18, 2024

The problem seems to be with systemctl:

$ systemctl --force --user edit foobar
"WITH-EDITOR:: 1: "WITH-EDITOR:: Syntax error: Unterminated quoted string
editor failed with error code 2.
Editing "/home/jonas/.config/systemd/user/foobar.service" canceled: temporary file is empty.
$ git commit --allow-empty
WITH-EDITOR: 13488 OPEN /home/jonas/.git/modules/emacs.d/modules/with-editor/COMMIT_EDITMSG
[gelpa 2d6f50c] test
$

Could you please try to find some documentation about what assumptions it makes about the value of $EDITOR? It looks like it some how chops of part of it. The value set by with-editor looks like sh -c '...'.

from with-editor.

jabranham avatar jabranham commented on September 18, 2024

In man systemctl, it just says:

ENVIRONMENT
       $SYSTEMD_EDITOR
           Editor to use when editing units; overrides $EDITOR and $VISUAL. If neither $SYSTEMD_EDITOR nor $EDITOR nor $VISUAL are present or if it is set
           to an empty string or if their execution failed, systemctl will try to execute well known editors in this order: editor(1), nano(1), vim(1),
           vi(1).

from with-editor.

npostavs avatar npostavs commented on September 18, 2024

Similar problem in Emacs Bug#9051/25082:

The documentation in environ(7) just says:

   EDITOR/VISUAL
          The user's preferred utility to edit text files.

However, I can't find a program that interprets it as a literal filename.

For example, Debian's sensible-editor editor-wrapper script does exactly
what I just did. If I set

export EDITOR='"spacey editor"'

it complains it can't find a program called: "spacey

If I do

 export EDITOR="emacsclient -c"

it works nicely. So it doesn't parse quotes specially. However, that's not
cross-platform.

from with-editor.

tarsius avatar tarsius commented on September 18, 2024

Similar problem in Emacs

But that is the only relation to the issue at hand. The problem in this case isn't that Emacs doesn't attempt to handle ALTERNATE_EDITOR as one would expect but that systemd, while trying to do so, actually fails to handle EDITOR/SYSTEMD_EDITOR as one would expect.

systemd can handle something like EDITOR="emacsclient -c". However if the value contains a quote or double quote, then it fails:

% SYSTEMD_EDITOR="sh -c \"echo huhu\"" systemctl --force --user edit foobar      
huhu": 1: huhu": Syntax error: Unterminated quoted string
editor failed with error code 2.
Editing "/home/jonas/.config/systemd/user/foobar.service" canceled: temporary file is empty.

% SYSTEMD_EDITOR="sh -c 'echo huhu'" systemctl --force --user edit foobar  
huhu': 1: huhu': Syntax error: Unterminated quoted string
editor failed with error code 2.
Editing "/home/jonas/.config/systemd/user/foobar.service" canceled: temporary file is empty.

There is nothing we can do here to work around this issue, so I am closing this.

from with-editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.