From 8e366732bb1ea6c38c01c003f6990eb1cbdf63cd Mon Sep 17 00:00:00 2001 From: xonixx Date: Tue, 31 Dec 2024 02:13:16 +0200 Subject: [PATCH] rm unused and undocumented global variable MYDIR #178 --- makesure.awk | 2 +- tests/200_update.sh | 2 +- tests/2_mydir.sh | 17 ++--------------- tests/2_mydir.tush | 13 +------------ tests/4_trace.tush | 32 -------------------------------- tests/7_options.tush | 2 -- tests/dir with spaces/2_mydir.sh | 2 +- tests/unify_tracing_output.awk | 2 +- 8 files changed, 7 insertions(+), 65 deletions(-) diff --git a/makesure.awk b/makesure.awk index 521670a..ac5fa49 100755 --- a/makesure.awk +++ b/makesure.awk @@ -34,7 +34,7 @@ BEGIN { Mode = "prelude" # prelude|define|goal|goal_glob|lib srand() prepareArgs() - MyDirScript = "MYDIR=" quoteArg(getMyDir(ARGV[1])) ";export MYDIR;cd \"$MYDIR\"" + MyDirScript = "cd " quoteArg(getMyDir(ARGV[1])) Error = "" makesure() } diff --git a/tests/200_update.sh b/tests/200_update.sh index a90c75d..dad76c3 100644 --- a/tests/200_update.sh +++ b/tests/200_update.sh @@ -26,7 +26,7 @@ @lib function prepare_makesure() { - awk -v X="$(cd "$MYDIR/.."; pwd)" '/AWK_DIR=/{ $0 = "AWK_DIR=" X } 1' "../$MAKESURE" > "$D/$MAKESURE" + awk -v X="$(cd ..; pwd)" '/AWK_DIR=/{ $0 = "AWK_DIR=" X } 1' "../$MAKESURE" > "$D/$MAKESURE" chmod +x "$D/$MAKESURE" } function run_selfupdate() { diff --git a/tests/2_mydir.sh b/tests/2_mydir.sh index 1177460..e39727e 100644 --- a/tests/2_mydir.sh +++ b/tests/2_mydir.sh @@ -6,9 +6,6 @@ @goal mydir_2 cat ./2_mydir.txt -@goal mydir_3 - cat "$MYDIR/2_mydir.txt" - @goal mydir_in_reached_if_1 @reached_if [[ -f 2_mydir.txt ]] echo "should not show" @@ -17,10 +14,6 @@ @reached_if [[ -f ./2_mydir.txt ]] echo "should not show" -@goal mydir_in_reached_if_3 -@reached_if [[ -f "$MYDIR/2_mydir.txt" ]] - echo "should not show" - @goal mydir_in_reached_if_4 @reached_if [[ ! -f 2_mydir.txt ]] echo "should show" @@ -29,10 +22,6 @@ @reached_if [[ ! -f ./2_mydir.txt ]] echo "should show" -@goal mydir_in_reached_if_6 -@reached_if [[ ! -f "$MYDIR/2_mydir.txt" ]] - echo "should show" - @goal mydir_in_reached_if_of_dep_1 @depends_on dep_1 echo "should show" @@ -43,14 +32,12 @@ @goal dep_1 @depends_on dep_3 -#@reached_if echo "#$MYDIR#"; [[ -f "$MYDIR/2_mydir.txt" ]] -@reached_if [[ -f "$MYDIR/2_mydir.txt" ]] +@reached_if [[ -f "./2_mydir.txt" ]] echo "should not show" @goal dep_2 @depends_on dep_3 -#@reached_if echo "#$MYDIR#"; [[ ! -f "$MYDIR/2_mydir.txt" ]] -@reached_if [[ ! -f "$MYDIR/2_mydir.txt" ]] +@reached_if [[ ! -f "./2_mydir.txt" ]] echo "should show" @goal dep_3 diff --git a/tests/2_mydir.tush b/tests/2_mydir.tush index ac0bd18..dc03607 100644 --- a/tests/2_mydir.tush +++ b/tests/2_mydir.tush @@ -7,15 +7,11 @@ $ ./$MAKESURE -f tests/2_mydir.sh mydir_2 | goal 'mydir_2' ... | mydir -$ ./$MAKESURE -f tests/2_mydir.sh mydir_3 -| goal 'mydir_3' ... -| mydir - $ ./$MAKESURE -f tests/dir\ with\ spaces/2_mydir.sh | goal 'default' ... | mydir -$ cd "$MYDIR/tests/dir with spaces"; ../../$MAKESURE -f 2_mydir.sh +$ cd "tests/dir with spaces"; ../../$MAKESURE -f 2_mydir.sh | goal 'default' ... | mydir @@ -25,9 +21,6 @@ $ ./$MAKESURE -f tests/2_mydir.sh mydir_in_reached_if_1 $ ./$MAKESURE -f tests/2_mydir.sh mydir_in_reached_if_2 | goal 'mydir_in_reached_if_2' [already satisfied]. -$ ./$MAKESURE -f tests/2_mydir.sh mydir_in_reached_if_3 -| goal 'mydir_in_reached_if_3' [already satisfied]. - $ ./$MAKESURE -f tests/2_mydir.sh mydir_in_reached_if_4 | goal 'mydir_in_reached_if_4' ... | should show @@ -36,10 +29,6 @@ $ ./$MAKESURE -f tests/2_mydir.sh mydir_in_reached_if_5 | goal 'mydir_in_reached_if_5' ... | should show -$ ./$MAKESURE -f tests/2_mydir.sh mydir_in_reached_if_6 -| goal 'mydir_in_reached_if_6' ... -| should show - $ ./$MAKESURE -f tests/2_mydir.sh mydir_in_reached_if_of_dep_1 | goal 'dep_1' [already satisfied]. | goal 'mydir_in_reached_if_of_dep_1' ... diff --git a/tests/4_trace.tush b/tests/4_trace.tush index f5875b7..6f7d8c7 100644 --- a/tests/4_trace.tush +++ b/tests/4_trace.tush @@ -13,29 +13,21 @@ $ ./$MAKESURE -f tests/4_trace.sh -x 2>&1 | awk -f tests/unify_tracing_o | goal 'default' ... | A=aaa @ + : default@reached_if -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + [[ 1 -eq 2 ]] @ + : goal2@reached_if -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + true @ + : goal1 -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + echo goal1 @ + : default -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @@ -48,29 +40,21 @@ $ ./$MAKESURE -f tests/4_trace.sh --tracing 2>&1 | awk -f tests/unify_tracing_o | goal 'default' ... | A=aaa @ + : default@reached_if -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + [[ 1 -eq 2 ]] @ + : goal2@reached_if -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + true @ + : goal1 -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + echo goal1 @ + : default -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @@ -91,29 +75,21 @@ $ ./$MAKESURE -f tests/4_trace_shell_sh.sh -x 2>&1 | awk -f tests/unify_ | goal 'default' ... | A=aaa @ + : default@reached_if -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + [ 1 -eq 2 ] @ + : goal2@reached_if -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + true @ + : goal1 -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + echo goal1 @ + : default -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @@ -126,29 +102,21 @@ $ ./$MAKESURE -f tests/4_trace_shell_sh.sh --tracing 2>&1 | awk -f tests/unify_ | goal 'default' ... | A=aaa @ + : default@reached_if -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + [ 1 -eq 2 ] @ + : goal2@reached_if -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + true @ + : goal1 -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A @ + echo goal1 @ + : default -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + A=aaa @ + export A diff --git a/tests/7_options.tush b/tests/7_options.tush index 59838b5..06a6a8c 100644 --- a/tests/7_options.tush +++ b/tests/7_options.tush @@ -18,7 +18,5 @@ $ ./$MAKESURE -f tests/7_options_tracing.sh 2>&1 | awk -f tests/unify_tracing_ | goal 'default' ... | test @ + : default -@ + MYDIR=/some/path/tests -@ + export MYDIR @ + cd /some/path/tests @ + echo test diff --git a/tests/dir with spaces/2_mydir.sh b/tests/dir with spaces/2_mydir.sh index c854e3f..ab54149 100644 --- a/tests/dir with spaces/2_mydir.sh +++ b/tests/dir with spaces/2_mydir.sh @@ -1,3 +1,3 @@ @goal default - cat "$MYDIR/2_mydir.txt" \ No newline at end of file + cat 2_mydir.txt \ No newline at end of file diff --git a/tests/unify_tracing_output.awk b/tests/unify_tracing_output.awk index 758ab26..d698192 100644 --- a/tests/unify_tracing_output.awk +++ b/tests/unify_tracing_output.awk @@ -1,5 +1,5 @@ { - sub(ENVIRON["MYDIR"],"/some/path") + sub(/cd .+\/tests/,"cd /some/path/tests") # my dir sub(/'\['/,"[") sub(/'\]'/,"]") sub(/echo 'A=aaa'/,"echo A=aaa")