diff mbox series

systemd: fix edit functionality with vi

Message ID 20260414190245.2182865-2-rs@ti.com
State Changes Requested
Headers show
Series systemd: fix edit functionality with vi | expand

Commit Message

Randolph Sapp April 14, 2026, 7:02 p.m. UTC
From: Randolph Sapp <rs@ti.com>

Systemd currently expects any $EDITOR to support +LINE functionality for
jumping to a specified line in a file. This makes busybox vi misbehave a
little as it opens a file called +LINE and shows the user this file
first, as it's the last argument passed to it.

This has been submitted upstream as even IEEE Std 1003.1-2024 doesn't
dictate that the default editors need to support +LINE functionality.

Signed-off-by: Randolph Sapp <rs@ti.com>
---
 ...ot-assume-the-editor-can-handle-LINE.patch | 46 +++++++++++++++++++
 meta/recipes-core/systemd/systemd_259.5.bb    |  1 +
 2 files changed, 47 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch

Comments

Adam Duskett April 15, 2026, 9:22 a.m. UTC | #1
Hello;

And the pull request for systemd to not assume an editor can handle +LINE
is here:
https://github.com/systemd/systemd/pull/41642

Poettering has closed the pull request with the following reasoning:
```
Uh, there's a myriad of tools that rely on this, not just "systemctl edit".
for example "less" does.
Maybe fix your editor if – in 2026 – it still doesn't support this. I am
really sure we shouldn't participate
in such a race to the bottom for really really really old editors, that
don't do what every other editor does.
Moreover we have been doing this for a whole decade now, and no one
complained, I am pretty sure we
shouldn't make things less usable now, a decade later because of some
ancient editor once upon a time
hasn't been updated to match what everybody else does, including all
vi-style editors of more recent date.
I might be more impressed if you convinced less to drop support for calling
$EDITOR with "+".

Or to express this in a more positive way: please prepare a patch to your
"vi" flavour of choice to add
support for this very established syntax instead.
```

A patch to add +LINE support to Busybox's VI was submitted on the 4th of
June 2024:
https://lists.busybox.net/pipermail/busybox/2024-June/090778.html and has
subsequently
been ignored without feedback.

Like it or not, Poettering has made it clear that this patch will not be
supported upstream,
and his reasoning is sound. The correct thing to do (in my opinion) would
be to bother
the busybox maintainers to apply the 23 line patch to add support to a
feature used in almost
every editor out there.

Either way, should we really be pulling in a patch like this that won't
ever be accepted upstream?

On Tue, Apr 14, 2026 at 9:03 PM Randolph Sapp via lists.openembedded.org
<rs=ti.com@lists.openembedded.org> wrote:

> From: Randolph Sapp <rs@ti.com>
>
> Systemd currently expects any $EDITOR to support +LINE functionality for
> jumping to a specified line in a file. This makes busybox vi misbehave a
> little as it opens a file called +LINE and shows the user this file
> first, as it's the last argument passed to it.
>
> This has been submitted upstream as even IEEE Std 1003.1-2024 doesn't
> dictate that the default editors need to support +LINE functionality.
>
> Signed-off-by: Randolph Sapp <rs@ti.com>
> ---
>  ...ot-assume-the-editor-can-handle-LINE.patch | 46 +++++++++++++++++++
>  meta/recipes-core/systemd/systemd_259.5.bb    |  1 +
>  2 files changed, 47 insertions(+)
>  create mode 100644
> meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch
>
> diff --git
> a/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch
> b/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch
> new file mode 100644
> index 0000000000..cbcb472201
> --- /dev/null
> +++
> b/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch
> @@ -0,0 +1,46 @@
> +From bc4177de928fa9c80f2cdd70fd79d07a37d7b2e2 Mon Sep 17 00:00:00 2001
> +From: Randolph Sapp <rs@ti.com>
> +Date: Tue, 14 Apr 2026 13:25:55 -0500
> +Subject: [PATCH] edit-util: do not assume the editor can handle +LINE
> +
> +If we're checking $EDITOR and trying to use an arbitrary list of text
> +editors we shouldn't just assume they know how to handle the +LINE
> +notation for jumping to a line in the specified file.
> +
> +Nano and Ed can handle it, but require that the line number is given
> +before the file. Vim and Neovim can take it as any positional argument
> +and just assume the last file specified was the intended target. Vi
> +cannot handle a line number specifier at all.
> +
> +There's nothing that states the $EDITOR has to take anything other than
> +a list of file names. Even that isn't really written anywhere. The
> +latest version of IEEE Std 1003.1-2024 does not indicate that the two
> +required utilities (vi and ex) need to support this functionality.
> +
> +Upstream-Status: Submitted [https://github.com/systemd/systemd/pull/41642
> ]
> +Signed-off-by: Randolph Sapp <rs@ti.com>
> +---
> + src/shared/edit-util.c | 7 -------
> + 1 file changed, 7 deletions(-)
> +
> +diff --git a/src/shared/edit-util.c b/src/shared/edit-util.c
> +index d48c36c1d5..b813c206c9 100644
> +--- a/src/shared/edit-util.c
> ++++ b/src/shared/edit-util.c
> +@@ -260,13 +260,6 @@ static int run_editor_child(const EditFileContext
> *context) {
> +                 }
> +         }
> +
> +-        if (context->n_files == 1 && context->files[0].line > 1) {
> +-                /* If editing a single file only, use the +LINE syntax
> to put cursor on the right line */
> +-                r = strv_extendf(&args, "+%u", context->files[0].line);
> +-                if (r < 0)
> +-                        return log_oom();
> +-        }
> +-
> +         FOREACH_ARRAY(i, context->files, context->n_files) {
> +                 r = strv_extend(&args, i->temp);
> +                 if (r < 0)
> +--
> +2.53.0
> +
> diff --git a/meta/recipes-core/systemd/systemd_259.5.bb
> b/meta/recipes-core/systemd/systemd_259.5.bb
> index d84e38d7cd..4f443cc2d0 100644
> --- a/meta/recipes-core/systemd/systemd_259.5.bb
> +++ b/meta/recipes-core/systemd/systemd_259.5.bb
> @@ -35,6 +35,7 @@ SRC_URI += " \
>             file://0003-Do-not-create-var-log-README.patch \
>             file://0001-meson-use-libfido2_cflags-dependency.patch \
>
> file://0018-shared-fdset-add-detailed-debug-logging-to-fdset_new.patch \
> +
>  file://0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch \
>             "
>
>  PAM_PLUGINS = " \
> --
> 2.53.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#235172):
> https://lists.openembedded.org/g/openembedded-core/message/235172
> Mute This Topic: https://lists.openembedded.org/mt/118828793/10152556
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> adam.duskett@amarulasolutions.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch b/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch
new file mode 100644
index 0000000000..cbcb472201
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch
@@ -0,0 +1,46 @@ 
+From bc4177de928fa9c80f2cdd70fd79d07a37d7b2e2 Mon Sep 17 00:00:00 2001
+From: Randolph Sapp <rs@ti.com>
+Date: Tue, 14 Apr 2026 13:25:55 -0500
+Subject: [PATCH] edit-util: do not assume the editor can handle +LINE
+
+If we're checking $EDITOR and trying to use an arbitrary list of text
+editors we shouldn't just assume they know how to handle the +LINE
+notation for jumping to a line in the specified file.
+
+Nano and Ed can handle it, but require that the line number is given
+before the file. Vim and Neovim can take it as any positional argument
+and just assume the last file specified was the intended target. Vi
+cannot handle a line number specifier at all.
+
+There's nothing that states the $EDITOR has to take anything other than
+a list of file names. Even that isn't really written anywhere. The
+latest version of IEEE Std 1003.1-2024 does not indicate that the two
+required utilities (vi and ex) need to support this functionality.
+
+Upstream-Status: Submitted [https://github.com/systemd/systemd/pull/41642]
+Signed-off-by: Randolph Sapp <rs@ti.com>
+---
+ src/shared/edit-util.c | 7 -------
+ 1 file changed, 7 deletions(-)
+
+diff --git a/src/shared/edit-util.c b/src/shared/edit-util.c
+index d48c36c1d5..b813c206c9 100644
+--- a/src/shared/edit-util.c
++++ b/src/shared/edit-util.c
+@@ -260,13 +260,6 @@ static int run_editor_child(const EditFileContext *context) {
+                 }
+         }
+
+-        if (context->n_files == 1 && context->files[0].line > 1) {
+-                /* If editing a single file only, use the +LINE syntax to put cursor on the right line */
+-                r = strv_extendf(&args, "+%u", context->files[0].line);
+-                if (r < 0)
+-                        return log_oom();
+-        }
+-
+         FOREACH_ARRAY(i, context->files, context->n_files) {
+                 r = strv_extend(&args, i->temp);
+                 if (r < 0)
+--
+2.53.0
+
diff --git a/meta/recipes-core/systemd/systemd_259.5.bb b/meta/recipes-core/systemd/systemd_259.5.bb
index d84e38d7cd..4f443cc2d0 100644
--- a/meta/recipes-core/systemd/systemd_259.5.bb
+++ b/meta/recipes-core/systemd/systemd_259.5.bb
@@ -35,6 +35,7 @@  SRC_URI += " \
            file://0003-Do-not-create-var-log-README.patch \
            file://0001-meson-use-libfido2_cflags-dependency.patch \
            file://0018-shared-fdset-add-detailed-debug-logging-to-fdset_new.patch \
+           file://0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch \
            "
 
 PAM_PLUGINS = " \