File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,15 +165,19 @@ run() {
165165 elif [[ ${FILE#* .} == java ]]; then
166166 javac " $FILE "
167167 JCF=$( find . -type f -name " *.class" -mmin -1 | cut -c 3-)
168+ classFileCount=$( find . -type f -name " *.class" -mmin -1 | wc -l)
169+
168170 if [[ $COMPILE != true ]]; then
169- while IFS= read -r classFile
171+ while [ " $classFileCount " -gt 0 ]
170172 do
171- mainMethodCheck=$( grep -q " main" " $classFile " && echo " mainMethod" )
172- if [[ $mainMethodCheck == " mainMethod" ]]; then
173+ classFile=$( echo " $JCF " | awk " NR==$classFileCount {print}" )
174+ mainMethodCheck=$( grep -q " main" " $classFile " && echo " mainMethodFound" )
175+ if [[ $mainMethodCheck == " mainMethodFound" ]]; then
173176 java " ${classFile%% .* } "
174177 break
175178 fi
176- done < <( printf ' %s\n' " $JCF " )
179+ (( classFile-- ))
180+ done
177181 fi
178182 if [[ $PERSISTENT != true ]]; then
179183 find . -type f -name " *.class" -mmin -2 -exec rm -rf {} \; 2> /dev/null
You can’t perform that action at this time.
0 commit comments