Treat empty environment variables as unset

This is slightly undefined, but it's more user-friendly to treat e.g. VISUAL=
the same as $VISUAL being unset. So to use e.g. RUST2RPM_NO_DETECT_PACKAGER,
"RUST2RPM_NO_DETECT_PACKAGER=1" must be used, and "RUST2RPM_NO_DETECT_PACKAGER="
is not enough.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-07-12 11:49:58 +02:00
parent 365d47a843
commit 59eb676441

View file

@ -31,13 +31,13 @@ def exit_on_common_errors():
def detect_editor():
terminal = os.getenv('TERM')
terminal_is_dumb = terminal is None or terminal == 'dumb'
terminal_is_dumb = not terminal or terminal == 'dumb'
editor = None
if not terminal_is_dumb:
editor = os.getenv('VISUAL')
if editor is None:
if not editor:
editor = os.getenv('EDITOR')
if editor is None:
if not editor:
if terminal_is_dumb:
raise Exception('Terminal is dumb, but $EDITOR unset')
editor = DEFAULT_EDITOR
@ -45,12 +45,11 @@ def detect_editor():
def detect_packager():
# If we're forcing the fallback...
if os.getenv('RUST2RPM_NO_DETECT_PACKAGER') is not None:
if os.getenv('RUST2RPM_NO_DETECT_PACKAGER'):
return None
# If we're supplying packager identity through an environment variable...
packager = os.getenv('RUST2RPM_PACKAGER')
if packager is not None:
if packager := os.getenv('RUST2RPM_PACKAGER'):
return packager
# If we're detecting packager identity through rpmdev-packager...