From 4521f99e97c6ef309f8586544019caece6672cc7 Mon Sep 17 00:00:00 2001 From: Xawirses Date: Thu, 2 Apr 2015 09:55:10 +0200 Subject: [PATCH] Add verification & NOTICE --- phase0.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/phase0.sh b/phase0.sh index ad496d6..22edf09 100755 --- a/phase0.sh +++ b/phase0.sh @@ -1,7 +1,22 @@ #!/bin/bash -TIME="$1 year ago" +if [ -z $1 ] ; then + echo "NOTICE : phase0.sh NbYear OutFiles" + exit 1; +else + if [ -z $2 ] ; then + echo "NOTICE : phase0.sh NbYear OutFiles" + exit 1; + fi +fi + +if [ $(echo $1 | grep -v [a-Z] | wc -l) -eq 0 ]; then + echo "Erreur : arg \$1 non entier positif !" + exit 1 +fi + +TIME="$1 year ago" IFS=$'\n' echo "Load data" @@ -11,14 +26,14 @@ LINES=(`git log --since="$TIME" --until="now" --no-merges --pretty=tformat: --s echo "Load word" WORD=(`git log --since="$TIME" --until="now" --no-merges --format=',%s'`) -echo "Create .csv" -touch gitlogy.csv +echo "Create $2" +touch $2 i=0 while [ $i -lt ${#DATA[@]} ]; do - echo "${DATA[$i]}${LINES[$i]}${WORD[$i]}" >> gitlogy.csv + echo "${DATA[$i]}${LINES[$i]}${WORD[$i]}" >> $2 i=$[i + 1] done echo "Parse message" -sed -i -e "s/\ /,/g" gitlogy.csv +sed -i -e "s/\ /,/g" $2