systemd: fix edit functionality with vi
PATCH 1/1 systemd: fix edit functionality with vi
From: Randolph Sapp <[email protected]>
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.
--- ...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
meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +46 -0
@@ -0,0 +1,46 @@ +From bc4177de928fa9c80f2cdd70fd79d07a37d7b2e2 Mon Sep 17 00:00:00 2001 +From: Randolph Sapp <[email protected]> +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 <[email protected]> +--- + 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 +
meta/recipes-core/systemd/systemd_259.5.bb +1 -0
@@ -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 = " \
Signature · 1 line
2.53.0
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?
Quoted 106 lines · Randolph Sapp via lists.openembedded.org
From: Randolph Sapp <[email protected]>
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 <[email protected]>--- ...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.patchdiff --git
a/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patchb/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patchnew 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.patchmeta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +20
-0@@ -0,0 +1,46 @@ +From bc4177de928fa9c80f2cdd70fd79d07a37d7b2e2 Mon Sep 17 00:00:00 2001 +From: Randolph Sapp <[email protected]> +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]
meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +10
-0+Signed-off-by: Randolph Sapp <[email protected]> +--- + 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) {
meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +5
-0+ } + } + +- if (context->n_files == 1 && context->files[0].line > 1) { +- /* If editing a single file only, use the +LINE syntaxto put cursor on the right line */
+- r = strv_extendf(&args, "+%u", context->files[0].line); +- if (r < 0) +- return log_oom(); +- } +-meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +6
-0+ FOREACH_ARRAY(i, context->files, context->n_files) { + r = strv_extend(&args, i->temp); + if (r < 0) +-- +2.53.0 +meta/recipes-core/systemd/systemd_259.5.bb +1
-0@@ -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: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 34 lines · Adam Duskett
Hello;
And the pull request for systemd to not assume an editor can handle +LINE is here:
https://github.com/systemd/systemd/pull/41642Poettering 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.
Quoted 7 lines
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.
Adding my reply here since it's being mentioned:
While I would normally agree with such sentiments, I'd like to reiterate IEEE Std 1003.1-2024 does not indicate that the two required editor utilities (vi and ex) need to support this functionality [1]. If you're going to try and use vi as a fallback, this doesn't make a lot of sense.
Additionally, as I pointed out earlier, nano needs the line number to come before the file name. If you believe this is really not your bug, shouldn't you at least avoid trying to open the editors you don't support?
[1] https://pubs.opengroup.org/onlinepubs/9799919799/
Not entirely sure where that's going to go.
Quoted 112 lines
Either way, should we really be pulling in a patch like this that won't ever be accepted upstream?
Quoted 106 lines · Randolph Sapp via lists.openembedded.org
From: Randolph Sapp <[email protected]>
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 <[email protected]>--- ...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.patchdiff --git
a/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patchb/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patchnew 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.patchmeta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +20
-0@@ -0,0 +1,46 @@ +From bc4177de928fa9c80f2cdd70fd79d07a37d7b2e2 Mon Sep 17 00:00:00 2001 +From: Randolph Sapp <[email protected]> +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]
meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +10
-0+Signed-off-by: Randolph Sapp <[email protected]> +--- + 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) {
meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +5
-0+ } + } + +- if (context->n_files == 1 && context->files[0].line > 1) { +- /* If editing a single file only, use the +LINE syntaxto put cursor on the right line */
+- r = strv_extendf(&args, "+%u", context->files[0].line); +- if (r < 0) +- return log_oom(); +- } +-meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +6
-0+ FOREACH_ARRAY(i, context->files, context->n_files) { + r = strv_extend(&args, i->temp); + if (r < 0) +-- +2.53.0 +meta/recipes-core/systemd/systemd_259.5.bb +1
-0@@ -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: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 50 lines · Randolph Sapp via lists.openembedded.org
Quoted 34 lines · Adam Duskett
Hello;
And the pull request for systemd to not assume an editor can handle +LINE is here:
https://github.com/systemd/systemd/pull/41642Poettering 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.Quoted 7 lines
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.Adding my reply here since it's being mentioned:
While I would normally agree with such sentiments, I'd like to reiterate IEEE Std 1003.1-2024 does not indicate that the two required editor utilities (vi and ex) need to support this functionality [1]. If you're going to try and use vi as a fallback, this doesn't make a lot of sense.
Quoted 4 lines
Additionally, as I pointed out earlier, nano needs the line number to come before the file name. If you believe this is really not your bug, shouldn't you at least avoid trying to open the editors you don't support?
Ignore that comment about nano. Part of my initial argument that there's not really a standard behavior in the way this is handled between editors right now.
Not entirely relevant if the argument is "I want to do it this way and anyone who doesn't support that is wrong."
I still believe falling back to an editor that doesn't support this behavior is inherently incorrect.
Quoted 108 lines
[1] https://pubs.opengroup.org/onlinepubs/9799919799/Not entirely sure where that's going to go.
Quoted 104 lines
Either way, should we really be pulling in a patch like this that won't ever be accepted upstream?
Quoted 98 lines · Randolph Sapp via lists.openembedded.org
From: Randolph Sapp <[email protected]>
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 <[email protected]>--- ...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.patchdiff --git
a/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patchb/meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patchnew 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.patchmeta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +20
-0@@ -0,0 +1,46 @@ +From bc4177de928fa9c80f2cdd70fd79d07a37d7b2e2 Mon Sep 17 00:00:00 2001 +From: Randolph Sapp <[email protected]> +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]
meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +10
-0+Signed-off-by: Randolph Sapp <[email protected]> +--- + 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) {
meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +5
-0+ } + } + +- if (context->n_files == 1 && context->files[0].line > 1) { +- /* If editing a single file only, use the +LINE syntaxto put cursor on the right line */
+- r = strv_extendf(&args, "+%u", context->files[0].line); +- if (r < 0) +- return log_oom(); +- } +-meta/recipes-core/systemd/systemd/0001-edit-util-do-not-assume-the-editor-can-handle-LINE.patch new file +6
-0+ FOREACH_ARRAY(i, context->files, context->n_files) { + r = strv_extend(&args, i->temp); + if (r < 0) +-- +2.53.0 +meta/recipes-core/systemd/systemd_259.5.bb +1
-0@@ -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