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

nano: set default shell editor to nano #25636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

protectivedad
Copy link

The default editor for the system is vi this exports the EDITOR shell variable as nano. Utilities like crontab that respect EDITOR will use nano by default.

Maintainer: Hannu Nyman [email protected]
Compile tested: ipq40xx, generic, asus_map-ac2200
Run tested: 24.10-rc2

Description:
Simple change that creates an/etc/profile.d/nano.sh file with export EDITOR=/usr/bin/nano.

The default editor for the system is vi this exports the EDITOR shell
variable as nano. Utilities like crontab that respect EDITOR will use
nano by default.

Signed-off-by: Anthony Sepa <[email protected]>
@sideeffect42
Copy link

What makes you believe that every user who installs nano wants to use it as $EDITOR?
What if a user also installs mg, joe, jupp, vim, or any other editor? Do they all fight for being the default?

@stangri
Copy link
Member

stangri commented Dec 31, 2024

What makes you believe that every user who installs nano wants to use it as $EDITOR?
What if a user also installs mg, joe, jupp, vim, or any other editor? Do they all fight for being the default?

Good point! It would make sense to make the most popular package the default one. My hunch is that nano gets installed more often than mg, joe and jupp combined. I couldn't find any recent package statistics, @hnyman do you have an idea how to check?

@sideeffect42
Copy link

sideeffect42 commented Dec 31, 2024

Good point! It would make sense to make the most popular package the default one.

I disagree. Even if the others are less popular, some users will still prefer them over whatever is the most popular editor. With such a hard config, how would these people change their preference?
Also, with many devices having tiny flashes, on also has to take size into account.

To solve this issue properly, you would copy Debian's sensible-editor.
This would be EDITOR=/usr/bin/editor, with editor being something like this:

#!/bin/sh

if test -n "${EDITOR-}"
then
    :
elif test -s ~/.myeditor
then
    read -r EDITOR <~/.myeditor
else
    EDITOR=vi
fi

exec "${EDITOR}" "$@"

Users can then choose whichever editor they like most by just writing it's name or path to ~/.myeditor.

@stangri
Copy link
Member

stangri commented Dec 31, 2024

With such a hard config, how would these people change their preference?

Same way they change their preference now?

@protectivedad
Copy link
Author

protectivedad commented Dec 31, 2024

This change only effects if nano is installed. If you don't want nano don't install it. Is there really a large use-case for installing more then one editor?

@hnyman
Copy link
Contributor

hnyman commented Jan 1, 2025

I am just thinking that how common are the actual benefits in OpenWrt context? Which utilities actually utilise that variable to launch an editor? Crontab was mentioned, but what else?

@nshopik
Copy link

nshopik commented Jan 1, 2025

git will use EDITOR variable

@protectivedad
Copy link
Author

protectivedad commented Jan 1, 2025

Wow, this seems to have become complicated real fast. I figured that for the vast majority of people who specifically install nano as an editor they would want it to be used by any tools that are installed by default (crontab) or that they install themselves (git, I guess). This change allows that use-case to be automatically set up.

Who installs two or three editors on their router, just in case they need them? Why would that individual user stop the vast majority of users from having nano setup as the default. I named the profile nano.sh so it can co-exist with other editor packages that also want to automatically set themselves up. That way the person or persons who want more then one editor installed can remove the profiles that they don't want. And the majority of users can benefit from having the EDITOR variable setup when the nano package is installed.

@sideeffect42
Copy link

Is there really a large use-case for installing more then one editor?

Good point. OpenWrt already ships an editor (vi) installed by default. Why do you need another one?

Who installs two or three editors on their router, just in case they need them?

Systems are not always only used by one person. There may be multiple admins with different preferences.

Why would that individual user stop the vast majority of users from having nano setup as the default.

You can also turn this the other way round: how does your preference for nano justify the additional work created for other users who now need to remove this profile file after every sysupgrade?

I named the profile nano.sh so it can co-exist with other editor packages that also want to automatically set themselves up.

So your suggestion is that I now open a PR for mg to install /etc/profile.d/zzz-mg-the-best.sh to override EDITOR again?

The problem with your PR in my eyes is not that it introduces a way to configure a different EDITOR, my problem with it is that it only works for people whose favourite editor is nano.

Another thing to take into account: if you replace Dropbear with OpenSSH there exists the possibility of AcceptEnv EDITOR which allows clients to forward their preferred EDITOR.
This profile file would overwrite the forwarded EDITOR variable, breaking users existing workflows.

@protectivedad
Copy link
Author

Is there really a large use-case for installing more then one editor?

Good point. OpenWrt already ships an editor (vi) installed by default. Why do you need another one?

I don't. I always assumed people install nano, vim or whatever as a replacement for vi. Whatever they install they want to use as a default. So let's set it up as a default editor.

Who installs two or three editors on their router, just in case they need them?

Systems are not always only used by one person. There may be multiple admins with different preferences.

I feel this is just letting the minority getting in the way of the majority, who just want a replacement for vi and want it setup as such.

Why would that individual user stop the vast majority of users from having nano setup as the default.

You can also turn this the other way round: how does your preference for nano justify the additional work created for other users who now need to remove this profile file after every sysupgrade?

I think this is just a repeat of more then one person administrating a router. Unless there are individuals who use nano for script editing, vim for config editing and vi for plain text files. Who installs nano (or any second editor) not to be used.

I named the profile nano.sh so it can co-exist with other editor packages that also want to automatically set themselves up.

So your suggestion is that I now open a PR for mg to install /etc/profile.d/zzz-mg-the-best.sh to override EDITOR again?

Sure if you want to. Up to you. There could be some type of co-ordination or complicated logic to pick the right editor, but why? For the ten people who install vim (pick any editor) and nano? Keep it simple.

The problem with your PR in my eyes is not that it introduces a way to configure a different EDITOR, my problem with it is that it only works for people whose favourite editor is nano.

Again, I don't understand your point. It's for anyone who wants to replace the vi with nano (because this is a nano package change). For people who prefer vim (or any other editor) they can implement the same. It only is a problem in your router needs many different editors, scenario. Which I find to be very low usage, sand even then it can be solved. The first time they try to use the default editor it will use nano and they can override the EDITOR setting in their profile.

Another thing to take into account: if you replace Dropbear with OpenSSH there exists the possibility of AcceptEnv EDITOR which allows clients to forward their preferred EDITOR. This profile file would overwrite the forwarded EDITOR variable, breaking users existing workflows.

Again this is just a repeat of the many people administration the same router (oh and they all want to use different editors) scenario. Which again I find as very low usage.

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.

5 participants