mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-02 06:56:12 +02:00
Fix OS compatibility issues for editors with spaces, slashes, and quotes (#1153)
* Fix inverted POSIX check, refactor os_compat, and add tests for it * Fix missing parentheses and remove skip_win on test that is passing in Windows now * Fix expected quotes in quoted args * Make output clearer on failing test * Bringing skip_win back to test whose failure is a bit more complicated than expected
This commit is contained in:
parent
b6b6e7750e
commit
9e6cd8820f
7 changed files with 121 additions and 20 deletions
|
@ -1,6 +1,5 @@
|
|||
import logging
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
@ -10,6 +9,7 @@ from pathlib import Path
|
|||
from .color import ERROR_COLOR
|
||||
from .color import RESET_COLOR
|
||||
from .os_compat import on_windows
|
||||
from .os_compat import split_args
|
||||
|
||||
|
||||
def get_text_from_editor(config, template=""):
|
||||
|
@ -25,7 +25,7 @@ def get_text_from_editor(config, template=""):
|
|||
f.write(template)
|
||||
|
||||
try:
|
||||
subprocess.call(shlex.split(config["editor"], posix=on_windows) + [tmpfile])
|
||||
subprocess.call(split_args(config["editor"]) + [tmpfile])
|
||||
except Exception as e:
|
||||
error_msg = f"""
|
||||
{ERROR_COLOR}{str(e)}{RESET_COLOR}
|
||||
|
@ -47,7 +47,7 @@ def get_text_from_editor(config, template=""):
|
|||
|
||||
|
||||
def get_text_from_stdin():
|
||||
_how_to_quit = "Ctrl+z and then Enter" if on_windows else "Ctrl+d"
|
||||
_how_to_quit = "Ctrl+z and then Enter" if on_windows() else "Ctrl+d"
|
||||
print(
|
||||
f"[Writing Entry; on a blank line, press {_how_to_quit} to finish writing]\n",
|
||||
file=sys.stderr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue