mirror of
https://github.com/jtesta/ssh-audit.git
synced 2024-12-22 22:15:22 +01:00
Fixed unicode errors when printing the man page on Windows.
This commit is contained in:
parent
49cf91a902
commit
36094611ce
@ -58,12 +58,13 @@ from ssh_audit.ssh_socket import SSH_Socket
|
|||||||
from ssh_audit.utils import Utils
|
from ssh_audit.utils import Utils
|
||||||
from ssh_audit.versionvulnerabilitydb import VersionVulnerabilityDB
|
from ssh_audit.versionvulnerabilitydb import VersionVulnerabilityDB
|
||||||
|
|
||||||
|
# Only import colorama under Windows. Other OSes can natively handle terminal colors.
|
||||||
try: # pragma: nocover
|
if sys.platform == 'win32':
|
||||||
from colorama import init as colorama_init
|
try:
|
||||||
colorama_init(strip=False) # pragma: nocover
|
from colorama import init as colorama_init
|
||||||
except ImportError: # pragma: nocover
|
colorama_init()
|
||||||
pass
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def usage(err: Optional[str] = None) -> None:
|
def usage(err: Optional[str] = None) -> None:
|
||||||
@ -1014,6 +1015,10 @@ def main() -> int:
|
|||||||
out = OutputBuffer()
|
out = OutputBuffer()
|
||||||
aconf = process_commandline(out, sys.argv[1:], usage)
|
aconf = process_commandline(out, sys.argv[1:], usage)
|
||||||
|
|
||||||
|
# If we're on Windows, but the colorama module could not be imported, print a warning if we're in verbose mode.
|
||||||
|
if (sys.platform == 'win32') and ('colorama' not in sys.modules):
|
||||||
|
out.v("WARNING: colorama module not found. Colorized output will be ddisabled.", write_now=True)
|
||||||
|
|
||||||
# If we're outputting JSON, turn off colors and ensure 'info' level messages go through.
|
# If we're outputting JSON, turn off colors and ensure 'info' level messages go through.
|
||||||
if aconf.json:
|
if aconf.json:
|
||||||
out.json = True
|
out.json = True
|
||||||
|
@ -106,7 +106,7 @@ echo "Processing man page at ${MAN_PAGE} and placing output into ${GLOBALS_PY}..
|
|||||||
echo WINDOWS_MAN_PAGE = '"""' >> "$GLOBALS_PY"
|
echo WINDOWS_MAN_PAGE = '"""' >> "$GLOBALS_PY"
|
||||||
# The 'ul' tool would be necessary if running under Linux to convert the overstrike characters into ANSI escape sequences.
|
# The 'ul' tool would be necessary if running under Linux to convert the overstrike characters into ANSI escape sequences.
|
||||||
# MANWIDTH=80 MAN_KEEP_FORMATTING=1 man "$MAN_PAGE" | ul >> "$GLOBALS_PY"
|
# MANWIDTH=80 MAN_KEEP_FORMATTING=1 man "$MAN_PAGE" | ul >> "$GLOBALS_PY"
|
||||||
MANWIDTH=80 MAN_KEEP_FORMATTING=1 man "./$MAN_PAGE" >> "$GLOBALS_PY"
|
MANWIDTH=80 MAN_KEEP_FORMATTING=1 man "./$MAN_PAGE" | sed $'s/\u2010/-/g' >> "$GLOBALS_PY"
|
||||||
echo '"""' >> "$GLOBALS_PY"
|
echo '"""' >> "$GLOBALS_PY"
|
||||||
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
Loading…
Reference in New Issue
Block a user