2017-12-19 7 views
0

現在のディレクトリのサブディレクトリにすべてのmavenプロジェクトをビルドしようとしています。私のシェルスクリプトは、ファイルが存在するかどうかにかかわらずpomファイルが見つかったと言っています。私が何か悪いことをしているかどうかはわかりません。誰かが助けてくれますか?シェルスクリプトを使用して現在のディレクトリでpom.xmlを見つける

私のシェルスクリプトは、それが何かを見つけるしない場合でも、

#!/bin/bash 
############################################################# 
#Simple script to build all project in the current directory 
############################################################# 

dirlist=$(find $1 -mindepth 1 -maxdepth 1 -type d) 

for dir in $dirlist 
do 
    (
    cd $dir 
    echo "############################################################################" 
    echo "inside directory: " $dir 
    echo "############################################################################" 
    git checkout development 
    git pull 
    if find . -maxdepth 1 -type f -name "pom.xml" # <- this is always true# 
    then 
    echo "========== Pom file exists to going for building ========= " 
    mvn clean install -DskipTests=true 
    fi 
    ) 
done 

答えて

1

findの終了ステータスが0です。たとえば、空でないディレクトリの-deleteのような場合は0ではありませんが、何も見つけられない場合はゼロではありません。

$ ls 
file1.txt 
$ find -name 'file2.txt' 
$ echo $? 
0 
あなただけではなく、あなたの状態で存在するかどうかを確認でき

if [[ -e 'pom.xml' ]]; then 
関連する問題