Cannot open the editor when the EDITOR variable contains argument
If we try to use release-new
with the EDITOR
environment variable which contains argument (example: nano -r
), the FileNotFoundError
exception is raise, since the subprocess.call
method try to find a binary with the full content of the environment variable.
Traceback (most recent call last):
File "/release-new/bin/release-new", line 8, in <module>
sys.exit(main())
^^^^^^
File "/release-new/lib/python3.11/site-packages/release_new/main.py", line 121, in main
do_release(
File "/release-new/lib/python3.11/site-packages/release_new/main.py", line 352, in do_release
subprocess.check_call([f"{text_editor_command}", f"{changelog_path}"])
File "/usr/lib/python3.11/subprocess.py", line 408, in check_call
retcode = call(*popenargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 389, in call
with Popen(*popenargs, **kwargs) as p:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.11/subprocess.py", line 1953, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'nano -r'
The solution is to split the content of the variable with shlex.split
in the call
method.