Skip to content

Commit

Permalink
[update] Keep only one cp_backup implementation.
Browse files Browse the repository at this point in the history
The two versions of cp_backup were mostly identical with a difference
of only one line.  Because of that, the benefit of checking the
condition only once, is overpowered by duplicating code, thus merging
the two implementations into one.
  • Loading branch information
mina86 committed Nov 25, 2012
1 parent 65bea82 commit 8303ce0
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions update
Expand Up @@ -101,24 +101,16 @@ fi
##
## Backup & copy
##
if $BACKUP; then
cp_backup () {
if ! [ -e "$2" ]; then
cp -v -- "$1" "$2"
elif ! cmp -s -- "$1" "$2" && ask "$1" "$2"; then
cp_backup() {
if ! [ -e "$2" ]; then
cp -v -- "$1" "$2"
elif ! cmp -s -- "$1" "$2" && ask "$1" "$2"; then
if $BACKUP; then
mv -- "$2" "$2~"
cp -v -- "$1" "$2"
fi
}
else
cp_backup () {
if ! [ -e "$2" ]; then
cp -v -- "$1" "$2"
elif ! cmp -s -- "$1" "$2" && ask "$1" "$2"; then
cp -v -- "$1" "$2"
fi
}
fi
cp -v -- "$1" "$2"
fi
}


##
Expand Down

0 comments on commit 8303ce0

Please sign in to comment.