bulletmark / edir

Program to rename, remove, and copy files and directories using your editor
139 stars 8 forks source link

Editor argument throws error #2

Closed eater closed 3 years ago

eater commented 3 years ago

Edir looks cool and I just installed it and got this:

$ VISUAL="gvim --nofork"
$ edir ./*.mobi
Traceback (most recent call last):
  File "/usr/local/bin/edir", line 4, in <module>
    exit(main())
  File "/usr/local/lib/python3.6/dist-packages/edir.py", line 316, in main
    editfile(fp.name)
  File "/usr/local/lib/python3.6/dist-packages/edir.py", line 211, in editfile
    res = subprocess.run(editcmd, stdin=tty)
  File "/usr/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gvim --nofork': 'gvim --nofork'

Also it seems to ignore the $EDIR_EDITOR environment variable?

$ EDIR_EDITOR="/usr/local/bin/gvim"  
$ edir ./*.mobi   
Traceback (most recent call last):
  File "/usr/local/bin/edir", line 4, in <module>
    exit(main())
  File "/usr/local/lib/python3.6/dist-packages/edir.py", line 316, in main
    editfile(fp.name)
  File "/usr/local/lib/python3.6/dist-packages/edir.py", line 211, in editfile
    res = subprocess.run(editcmd, stdin=tty)
  File "/usr/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gvim --nofork': 'gvim --nofork'
bulletmark commented 3 years ago

Sorry, I just happened to spot this bug now. For some odd reason github did not automatically subscribe me to this issue so I got no email/notification.

I will fix the first issue you state. Regarding your second issue, that is not a bug, that is how the shell works. For child processes to see the shell variable you must export it first, e.g.:

$ export EDIR_EDITOR="/usr/local/bin/gvim"  
$ edir ./*.mobi   
bulletmark commented 3 years ago

Fixed in commit 8bad00f1093826ff98aed4644711958f23782b19.

eater commented 3 years ago

Live and learn!