From c39ac392c08db285f1e6bc77cf377cbfdcbbb6c3 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 19 Sep 2019 01:04:06 -0400 Subject: [PATCH] fixes --- bake/bakefile.py | 5 +++-- bake/cli.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bake/bakefile.py b/bake/bakefile.py index 3d83f57..14a4283 100644 --- a/bake/bakefile.py +++ b/bake/bakefile.py @@ -307,7 +307,8 @@ class TaskScript(BaseAction): # Grab the first source line, for shebang comparison. try: - first_natural_line = sources[0].split("\n", 1)[0] + # Last script comes first. + first_natural_line = sources[-1].split("\n", 1)[0] except IndexError: # TODO: maybe not. first_natural_line = "#!/usr/bin/env bash" @@ -318,7 +319,7 @@ class TaskScript(BaseAction): yield shebang if insert_source and Bakefile._is_safe_to_inject(shebang=shebang): - init_source = f"source <(bake --source {insert_source})" + init_source = f". <(bake --source {insert_source})" yield init_source source_container.extend(sources) diff --git a/bake/cli.py b/bake/cli.py index e15f1ef..6045935 100644 --- a/bake/cli.py +++ b/bake/cli.py @@ -249,7 +249,11 @@ def entrypoint( else: task = bakefile.tasks[source] source = task.gen_source( - sources=[task.source], + sources=[ + task.bashfile.funcs_source, + task.bashfile.root_source, + task.source, + ], remove_comments=True, insert_source="__init__", include_shebang=True,