sensible-editor fails when there is only one alternative

Bug #238879 reported by Dustin Kirkland 
4
Affects Status Importance Assigned to Milestone
debianutils (Ubuntu)
Fix Released
Low
Dustin Kirkland 

Bug Description

Binary package hint: debianutils

dustin@intrepid:~$ crontab -e
no crontab for dustin - using an empty one
.: 17: Can't open /home/dustin/.selected_editor
crontab: "/usr/bin/sensible-editor" exited with status 2

This occurs when `update-alternatives --list editor` only returns one entry.

To reproduce, remove the nano and ed packages, then run something that uses sensible-editor, such as dch.

I have a debdiff that fixes this. I will attach it in a subsequent post.

:-Dustin

Related branches

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Marking confirmed, as "geser" on #ubuntu-devel reported this issue, and I have confirmed it.

:-Dustin

Changed in debianutils:
assignee: nobody → kirkland
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

The pertinent code in sensible-editor looks like this:

if [ -r ~/.selected_editor ]; then
        . ~/.selected_editor
elif [ -z "$EDITOR" ] && [ -z "$SELECTED_EDITOR" ]; then
        select-editor && . ~/.selected_editor
fi

There's a problem if running select-editor does not write a ~/.selected_editor file. We should handle this by explicitly exiting 0 if it is created, and 1 otherwise in the select-editor utility.

Patch attached, requesting sponsorship.

:-Dustin

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Marking 'In Progress' ... patch awaiting sponsorship.

Changed in debianutils:
status: Confirmed → In Progress
Revision history for this message
Michael Bienia (geser) wrote :

I've applied the patch locally and can confirm that it fixes the issue.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package debianutils - 2.28.6ubuntu2

---------------
debianutils (2.28.6ubuntu2) intrepid; urgency=low

  * select-editor: ensure that select-editor exits 0 if and only if a
    ~/.selected_editor file is written, and exits 1 otherwise (LP: #238879).

 -- Dustin Kirkland <email address hidden> Tue, 10 Jun 2008 09:40:00 -0500

Changed in debianutils:
status: In Progress → Fix Released
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

I'm attaching an auxiliary patch, which would have also fixed this problem, but is also necessary for catching silly race conditions where .selected_editor exists, but then gets deleted before sourcing. None of this should cause user heart ache.

:-Dustin

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Bug in the previous patch, the parens will cause the sourcing to happen in a subshell--not what we want.

Updated patch attached.

:-Dustin

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Last patch said "hardy", not "intrepid". Argggh...

Updated accordingly.

:-Dustin

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.