summaryrefslogtreecommitdiff
path: root/src/abslibre-tools
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-05-03 01:02:59 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-03 01:39:15 -0400
commitf9141fda60ca94d9b1c75022f6129fabfab1cc6b (patch)
treed9d1095b94eca8c063e21b65655e4ced911afa7f /src/abslibre-tools
parent98f98dc4ce160518cd13f9953edf196debe95d4c (diff)
libredbdiff: Improve local variable usage
Diffstat (limited to 'src/abslibre-tools')
-rwxr-xr-xsrc/abslibre-tools/libredbdiff13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/abslibre-tools/libredbdiff b/src/abslibre-tools/libredbdiff
index 50208f2..bb2d4c0 100755
--- a/src/abslibre-tools/libredbdiff
+++ b/src/abslibre-tools/libredbdiff
@@ -46,6 +46,7 @@ downloadfile() {
local outfile=$1
local url=$2
local mesg=("${@:3}")
+
if [[ ! -e "$outfile" ]] ; then
msg "${mesg[@]}"
if wget -q "$url" -O "$outfile"; then
@@ -59,18 +60,22 @@ downloadfile() {
}
enablerepo() {
- repo="$1"
- conffile_arg="$2"
+ local repo="$1"
+ local conffile_arg="$2"
+
msg2 "Enabling repo %q in %q" "$repo" "$conffile_arg"
sed -i "s/\#\[$repo\]/[$repo]/" "$conffile_arg"
sed -i "\/\[$repo\]/,+1 s/#Include/Include/" "$conffile_arg"
}
+# Globals:
+# - init
createdir() {
local dir=$1
+
if [[ ! -e "$dir" ]] ; then
msg "Creating directory %q" "$dir"
- mkdir -- "$1" || die "Failed to create directory %q. Exiting." "$dir"
+ mkdir -- "$dir" || die "Failed to create directory %q. Exiting." "$dir"
elif [[ -n "$init" ]]; then
warning "%q already exists. Skipping." "$dir"
fi
@@ -80,7 +85,9 @@ setmirror() {
local distro="$1"
local mirror="$2"
local mirrorlist="$3"
+
if [[ -n "$init" ]] && [[ -n "$mirror" ]]; then
+ local mirrorescaped
mirrorescaped="${mirror//./\\.}"
mirrorescaped="${mirrorescaped//\$/\\$}"
msg2 "Setting %s as the only enabled %s mirror." "$mirror" "$distro"