diff --git a/makesure.awk b/makesure.awk index 895b3ab..f1c5ad9 100755 --- a/makesure.awk +++ b/makesure.awk @@ -168,7 +168,7 @@ function handleLib() { if (libName in Lib) { die("Lib '" libName "' is already defined") } - arrPush(LibNames, script_name) + arrPush(LibNames, libName) Lib[libName] } @@ -334,7 +334,7 @@ body,goal_body,goal_bodies,resolved_goals,exit_code, t0,t1,t2, goal_timed, list) if ("tracing" in Options) addLine(goal_body, "set -x") addLine(goal_body, trim(Code[""])) - exit_code = shellExec(goal_body[0]) + exit_code = shellExec(goal_body[0]) # TODO optimize : don't exec empty prelude if (exit_code != 0) realExit(exit_code) @@ -381,6 +381,8 @@ body,goal_body,goal_bodies,resolved_goals,exit_code, t0,t1,t2, goal_timed, list) addLine(goal_body, "exit 0") addLine(goal_body, defines_line[0]) + if (goal_name in GoalToLib) + addLine(goal_body, Lib[GoalToLib[goal_name]]) # TODO handle unknown lib if ("tracing" in Options) addLine(goal_body, "set -x") diff --git a/tests/16_lib.sh b/tests/16_lib.sh index 718a36c..739ba71 100644 --- a/tests/16_lib.sh +++ b/tests/16_lib.sh @@ -16,4 +16,4 @@ f1 World @goal g2 @use_lib lib_name -f1 World +f2 World diff --git a/tests/16_lib.tush b/tests/16_lib.tush index e4e14b1..44ee163 100644 --- a/tests/16_lib.tush +++ b/tests/16_lib.tush @@ -2,11 +2,15 @@ $ cd "$MYDIR"; ./makesure -f tests/16_lib.sh -l | Available goals: -| a -| 15_private.sh +| g1 +| g2 $ cd "$MYDIR"; ./makesure -f tests/16_lib.sh g1 +| goal 'g1' ... +| Hello World $ cd "$MYDIR"; ./makesure -f tests/16_lib.sh g2 +| goal 'g2' ... +| Hello lib_name World