Projet

Général

Profil

Révision 3e9236bd

Ajouté par Julien Enselme il y a plus de 9 ans

Update scritp so they respect the new convention.

  • Variables are quoted.
  • $(…) are quoted.

Voir les différences:

bin/flush-files.sh
6 6
# from the terminal."
7 7

  
8 8
# Check if scripts-utils.sh is imported.
9
if [ -z $scripts_utils ] ; then
9
if [ -z "${scripts_utils}" ] ; then
10 10
    echo "Import of scripts-utils.sh required."
11 11
    . scripts-utils.sh
12 12
fi
13 13

  
14
check_arguments $# 1 "$help"
14
check_arguments "$#" 1 "$help"
15 15

  
16
# Must not be quoted to avoid problem with ((…))
16 17
backups_number=$(ls | wc -l)
17
let "number_of_backups_to_delete = backups_number - $1" > /dev/null
18
((number_of_backups_to_delete = backups_number - $1))
18 19

  
19
if [ $number_of_backups_to_delete -gt 0 ] ; then
20
    ls | head -$number_of_backups_to_delete | xargs rm
20
if [ "${number_of_backups_to_delete}" -gt 0 ] ; then
21
    ls | head "-${number_of_backups_to_delete}" | xargs rm
21 22
else
22
    if [ ! -z $2 ] ; then
23
        dir=$(pwd)
24
        echo "There are not enough files in $dir to Flush it. Check if backup script works fine." | mail -s "[db] $dir has a backup problem" $2
23
    if [ ! -z "$2" ] ; then
24
        dir="$(pwd)"
25
        echo "There are not enough files in $dir to Flush it. Check if backup script works fine." | mail -s "[db] $dir has a backup problem" "$2"
25 26
    fi
26 27
fi

Formats disponibles : Unified diff