diff --git a/home/jashton.nix b/home/jashton.nix index 327ba08..b620813 100644 --- a/home/jashton.nix +++ b/home/jashton.nix @@ -91,16 +91,20 @@ in cd "$ROOT" mkdir -p bin - SOURCES="$1" - - find "$SOURCES" -name '*.java' -path '*.java' + # Set the target directory, defaulting to the current directory (.) if $1 is empty + TARGET_DIR="$1" + SOURCES_FILE="SOURCES" - if [ ! -s "$SOURCES" ]; then - echo "jbuild: no .java files found under ./$SOURCES" >&2 + # Fix the find command to safely search the target directory + find "$TARGET_DIR" -name '*.java' > "$SOURCES_FILE" + + if [ ! -s "$SOURCES_FILE" ]; then + # Fix the error message to reference the directory, not the output text file + echo "jbuild: no .java files found under $TARGET_DIR" >&2 exit 1 fi - javac -g --release 21 -encoding UTF-8 -d bin -cp "lib/*" @"$SOURCES" + javac -g --release 21 -encoding UTF-8 -d bin -cp "lib/*" @"$SOURCES_FILE" '') (pkgs.writeShellScriptBin "jclean" ''