Evaluate EDITOR and VISUAL with the shell

It is generally understood that the EDITOR and VISUAL environment variables must be passed to the shell. This is required for several reasons:

  • First, the user must be able to specify quoted arguments in the value, such as in this case: vim +'setf perl'.
  • Second, the user must be able to specify arbitrary shell so that they can handle cases like the presence or lack of DISPLAY or falling back to a less desirable editor if the preferred editor is missing.

In order for this to work, the environment variables must be evaluated by the shell. sensible-editor does not do this: it simply subjects them to shell word splitting, which is not sufficient to make either of these cases work. However, other tools, such as less, mutt, crontab, and git, do indeed perform this behavior.

To make this functionality work properly, let's call eval on the output of those variables.

In addition, let's add a test and improve that test so that it's more reliable when building the package on developers' systems.

Merge request reports

Loading