Skip to content

Commit

Permalink
Fix bug if using hab env - introduced by last release
Browse files Browse the repository at this point in the history
Args was None when not using the launch sub-command this broke the logging
message even though it wasn't being used.
  • Loading branch information
MHendricks committed Jun 3, 2024
1 parent bc3eae4 commit 8dc789b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions hab/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,17 @@ def write_script(
# Otherwise just process the uri like normal
cfg = self.resolver.resolve(uri)

msg = f"Launching alias: {launch} {' '.join(args)} for URI: {cfg.uri}"
if launch:
_args = f" {' '.join(args)}" if args else ""
launch_msg = f"Launching alias: {launch}{_args} for URI: {cfg.uri}"
if self.script_dir:
# Hab was called using the shell scripts, use them to launch the alias
# using the same system as `hab launch - alias_name`. This allows the
# python process used to parse the hab config to exit before the alias
# is launched ensuring that if something kills python processes it won't
# affect the launched alias or any host shells
if launch:
logger.info(f"{msg} using shell.")
logger.info(f"{launch_msg} using shell.")
cfg.write_script(
self.script_dir,
self.script_ext,
Expand All @@ -285,7 +287,7 @@ def write_script(
kwargs["stderr"] = None
kwargs["stdout"] = None

logger.info(f"{msg} as subprocess.")
logger.info(f"{launch_msg} as subprocess.")
proc = cfg.launch(launch, args, blocking=blocking, **kwargs)
if blocking:
sys.exit(proc.returncode)
Expand Down

0 comments on commit 8dc789b

Please sign in to comment.