X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=version-manifest%2Fsrc%2Fmain%2Fscripts%2Fcheck-sorted.sh;h=eb41ddef2aef06e6de5de0e94a309996b16c507e;hb=50fe3bb96fd34355aea2ec50199e328f59d16596;hp=d926409f4edb8f52230c36adbb9115e1e983906d;hpb=5faf6f21782da48fc8514235967aa4e4d8bfe6b1;p=integration.git diff --git a/version-manifest/src/main/scripts/check-sorted.sh b/version-manifest/src/main/scripts/check-sorted.sh index d926409f4..eb41ddef2 100755 --- a/version-manifest/src/main/scripts/check-sorted.sh +++ b/version-manifest/src/main/scripts/check-sorted.sh @@ -1,12 +1,28 @@ #!/bin/bash + +if [ "$#" -ne 1 ]; then + echo This script checks the input file to verify that it is sorted + echo "$0 " + exit 1 +fi + LC_ALL=C sort -c $1 + retval=$? if [ $retval -ne 0 ]; then echo - echo "ERROR: $1 is not properly sorted. Please sort it with the following commands:" + echo "[ERROR] $1 is not properly sorted. Please sort it with the following commands:" echo echo " LC_ALL=C sort < $1 > $1.tmp" echo " mv $1.tmp $1" echo fi + +# check that there are no duplicate records +DUPLICATES=$(rev < $1 | cut -f2- -d, | uniq -d | rev | tr ',' ':') +for DUP in $DUPLICATES; do + echo "[ERROR] $DUP has duplicate entries" + ((retval++)) +done + exit $retval