Re: Review of new man page of sensible-editor
I wrote:
> This really needs a whole new proposed version, but that isn't
> attached yet.
Attached; unfortunately I'm changing so much now that it's
overstretching my knowledge of nroff.
The big problem with the itemised list of stages is that although it
makes a good summary how sensible-editor's logic *should* work, when
you look at the script it turns out not to do what it says it does.
Much of the work is done by the line
${EDITOR:-${SELECTED_EDITOR:-editor}} "$@"
...which will try EDITOR if that's non-null, or SELECTED_EDITOR if
that's non-null, or /usr/bin/editor as a fallback. But this means if
my shell profile has
export EDITOR=nosuchprogram
then sensible-editor will try to execute that, receive an errorcode
127, and immediately fail over to running *nano* instead, regardless
of what the alternatives system says should be the system default!
So do we document this, or fix it?
--
JBR with qualifications in linguistics, experience as a Debian
sysadmin, and probably no clue about this particular package
.\" -*- nroff -*-
.TH SENSIBLE-EDITOR 1 "14 Nov 2018" "Debian"
.SH NAME
sensible-editor \- launch sensibly chosen text editor
.SH SYNOPSIS
.BR sensible-editor " ARGUMENTS..."
.br
.SH DESCRIPTION
.BR sensible-editor " makes sensible decisions on which editor to call.
Programs in Debian can invoke this script to get a good default editor.
.PP
sensible-editor looks for an appropriate choice of editor in a series
of places, and uses the first candidate that works.
It starts by checking environment variables,
followed by a variable defined via select-editor,
then tries the default editor command defined by the alternatives system,
with a series of hard-coded command names as fallbacks.
.PP
Variables will be skipped if unset or null, but may include extra
whitespace-separated parameters such as a
.I --verbose
flag.
Once sensible-editor has a candidate commandline, it will try to run
it (passing on the arguments it was given as the files to be edited).
If this fails because the command couldn't be executed (exit code 126)
or was not found (exit code 127), it tries the next candidate.
.PP
The specific candidates sensible-editor tries, in order, are:
.IP \(bu 2
.B $VISUAL
- see environ(7)
.IP \(bu 2
.B $EDITOR
- see environ(7)
.IP \(bu 2
.B $SENSIBLE_EDITOR
.IP \(bu 2
.B $SELECTED_EDITOR
- see select-editor(1)
.IP \(bu 2
.B editor
- see editor(1), update-alternatives(1)
.IP \(bu 2
.B nano
.IP \(bu 2
.B nano-tiny
.IP \(bu 2
.B vi
.PP
If all of these fail, sensible-editor errors out.
This system is designed to make it easy for individual users to
set a personal and/or temporary default, overriding the system-wide
defaults.
.SH BUGS
This command takes precautions against launching itself in an infinite loop
if a user sets
.B EDITOR=sensible-editor
but indirect loops are still possible.
.SH "SEE ALSO"
sensible-browser(1), sensible-pager(1), select-editor(1), environ(7),
editor(1), update-alternatives(1)
.SH "CONFORMS TO"
The behavior of sensible-utils under a Debian system is documented in
section 11.4 of Debian-Policy, available under
/usr/share/doc/debian-policy if debian-policy is installed, or
online at https://www.debian.org/doc/debian-policy/
Reply to: