Skip to content

Commit f3f1407

Browse files
committed
Remove unneeded double quotes
from download-distfiles.sh and mirror.sh
1 parent 19c83b8 commit f3f1407

File tree

2 files changed

+50
-50
lines changed

2 files changed

+50
-50
lines changed

download-distfiles.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,54 @@
77
# Optional arguments: Mirrors
88

99
download_source() {
10-
local distfiles="${1}"
11-
local url="${2}"
10+
local distfiles=${1}
11+
local url=${2}
1212
shift 2
13-
if [[ "${url}" == git://* ]]; then
14-
url="${1}"
13+
if [[ ${url} == git://* ]]; then
14+
url=${1}
1515
shift
1616
fi
17-
local checksum="${1}"
18-
local fname="${2}"
17+
local checksum=${1}
18+
local fname=${2}
1919
# Default to basename of url if not given
20-
fname="${fname:-$(basename "${url}")}"
20+
fname=${fname:-$(basename "${url}")}
2121
if [ "${fname}" = "_" ]; then
2222
echo "ERROR: ${url} must have a filename specified"
2323
exit 1
2424
fi
2525

26-
local dest_path="${distfiles}/${fname}"
26+
local dest_path=${distfiles}/${fname}
2727
if ! [ -e "${dest_path}" ]; then
2828
echo "Downloading ${fname}"
2929
if [ "${mirrors_len}" -ne 0 ]; then
30-
local mirror_ix="$((RANDOM % mirrors_len))"
31-
url="${mirrors[${mirror_ix}]}/${fname}"
30+
local mirror_ix=$((RANDOM % mirrors_len))
31+
url=${mirrors[${mirror_ix}]}/${fname}
3232
fi
3333
curl --fail --location "${url}" --output "${dest_path}" || true
3434
fi
3535
}
3636

3737
check_source() {
38-
local distfiles="${1}"
39-
local url="${2}"
38+
local distfiles=${1}
39+
local url=${2}
4040
shift 2
41-
if [[ "${url}" == git://* ]]; then
42-
url="${1}"
41+
if [[ ${url} == git://* ]]; then
42+
url=${1}
4343
shift
4444
fi
45-
local checksum="${1}"
46-
local fname="${2}"
45+
local checksum=${1}
46+
local fname=${2}
4747
# Default to basename of url if not given
48-
fname="${fname:-$(basename "${url}")}"
48+
fname=${fname:-$(basename "${url}")}
4949

50-
local dest_path="${distfiles}/${fname}"
50+
local dest_path=${distfiles}/${fname}
5151
echo "${checksum} ${dest_path}" | sha256sum -c
5252
}
5353

5454
set -e
5555

5656
mirrors=( "$@" )
57-
mirrors_len="$#"
57+
mirrors_len=$#
5858

5959
cd "$(dirname "$(readlink -f "$0")")"
6060
mkdir -p distfiles

mirror.sh

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
1212
exit 1
1313
fi
1414

15-
dest="$1"
15+
dest=$1
1616
if [ ! -d "${dest}" ]; then
1717
echo "${dest} must be a directory"
1818
exit 1
@@ -22,9 +22,9 @@ if [ ! -w "${dest}" ]; then
2222
echo "you must be able to write to ${dest}"
2323
exit 1
2424
fi
25-
dest="$(realpath "${dest}")"
25+
dest=$(realpath "${dest}")
2626

27-
state="$2"
27+
state=$2
2828
if [ "${state}" = "" ]; then
2929
state="${PWD}/mirrorstate"
3030
fi
@@ -34,8 +34,8 @@ state="$(realpath "${state}")"
3434

3535
# Download a HTTP file
3636
download_file() {
37-
url="${1}"
38-
out="${2}"
37+
url=${1}
38+
out=${2}
3939
# Download the file
4040
continue_arg=""
4141
if [ -e "${out}" ]; then
@@ -47,8 +47,8 @@ download_file() {
4747

4848
# Check if a git reference exists in a given repository
4949
git_ref_exists() {
50-
repo="${1}"
51-
ref="${2}"
50+
repo=${1}
51+
ref=${2}
5252
# change this to git show-ref once it is sufficiently not-new
5353
( cd "${repo}" || exit && git cat-file -t "${ref}" >/dev/null 2>&1 )
5454
return $?
@@ -59,21 +59,21 @@ checksum_file() {
5959
}
6060

6161
do_file() {
62-
uri="${1}"
62+
uri=${1}
6363
echo "${uri}"
6464

6565
if echo "${uri}" | grep -qE "^https?://"; then
6666
# HTTP file
67-
checksum="${2}"
68-
filename="${3}"
67+
checksum=${2}
68+
filename=${3}
6969
if [ "${filename}" = "" ]; then
70-
filename="$(basename "${uri}")"
70+
filename=$(basename "${uri}")
7171
fi
7272

7373
# Check if the file is already downloaded & the checksum is the same
74-
dest_file="${dest}/${filename}"
74+
dest_file=${dest}/${filename}
7575
if [ -e "${dest_file}" ]; then
76-
existing_checksum="$(checksum_file "${dest_file}")"
76+
existing_checksum=$(checksum_file "${dest_file}")
7777
if [ "${checksum}" = "${existing_checksum}" ]; then
7878
# There is nothing we need to do here
7979
return
@@ -82,10 +82,10 @@ do_file() {
8282

8383
# Attempt up to 2 times
8484
retries=2
85-
matching="no"
85+
matching=no
8686
while [ "${retries}" -gt 0 ]; do
8787
download_file "${uri}" "${dest}/${filename}"
88-
my_checksum="$(checksum_file "${dest_file}")"
88+
my_checksum=$(checksum_file "${dest_file}")
8989
if [ "${checksum}" = "${my_checksum}" ]; then
9090
matching="yes"
9191
break
@@ -105,28 +105,28 @@ do_file() {
105105
# Creating a tarball from a git repository
106106

107107
# Very unfortunately, different sites have different rules.
108-
uri_path="${uri#git://}"
108+
uri_path=${uri#git://}
109109
# GitHub does not have git:// protocol support
110110
if echo "${uri}" | grep -Eq "^git://github.com"; then
111-
uri="https://${uri_path}"
111+
uri=https://${uri_path}
112112
fi
113-
repo="${uri%~*}"
114-
outdir="${state}/git/${repo#*://}"
115-
reference="${uri##*~}"
113+
repo=${uri%~*}
114+
outdir=${state}/git/${repo#*://}
115+
reference=${uri##*~}
116116

117-
http_src="${2}"
118-
checksum="${3}"
119-
tarball="${4:-$(basename "${http_src}")}"
117+
http_src=${2}
118+
checksum=${3}
119+
tarball=${4:-$(basename "${http_src}")}
120120
if [ "${tarball}" = "_" ]; then
121121
echo "${uri}: ERROR! Must have tarball name if no http source."
122122
exit 1
123123
fi
124-
tarball="${dest}/${tarball}"
124+
tarball=${dest}/${tarball}
125125

126126
# Check if tarball already generated + matches checksum
127-
checksum="${3}"
127+
checksum=${3}
128128
if [ -e "${tarball}" ]; then
129-
existing_checksum="$(checksum_file "${tarball}")"
129+
existing_checksum=$(checksum_file "${tarball}")
130130
if [ "${existing_checksum}" = "${checksum}" ]; then
131131
return
132132
fi
@@ -151,13 +151,13 @@ do_file() {
151151
fi
152152

153153
# Generate the prefix for the tarball
154-
prefix_ref="${reference}"
154+
prefix_ref=${reference}
155155
# All git repositories we already use remove "v"s from the beginning
156156
# of branch/tag names in the tarball prefix
157157
if echo "${reference}" | grep -Eq "^v[0-9]"; then
158-
prefix_ref="$(echo "${reference}" | sed "s/^v//")"
158+
prefix_ref=$(echo "${reference}" | sed "s/^v//")
159159
fi
160-
prefix="$(basename "${repo}" | sed "s/.git$//")-${prefix_ref}"
160+
prefix=$(basename "${repo}" | sed "s/.git$//")-${prefix_ref}
161161

162162
(
163163
cd "${outdir}" || exit
@@ -168,7 +168,7 @@ do_file() {
168168
git archive "${reference}" -o "${tarball}" --prefix "${prefix}/"
169169
)
170170

171-
my_checksum="$(sha256sum "${tarball}" | cut -d' ' -f1)"
171+
my_checksum=$(sha256sum "${tarball}" | cut -d' ' -f1)
172172
if [ "${my_checksum}" != "${checksum}" ]; then
173173
echo "${uri}: generated tarball does not match checksum"
174174
exit 1
@@ -180,6 +180,6 @@ for src in steps/*/sources; do
180180
while read -r line; do
181181
# shellcheck disable=SC2086
182182
do_file ${line}
183-
uri="$(echo "${line}" | cut -d' ' -f1)"
183+
uri=$(echo "${line}" | cut -d' ' -f1)
184184
done < "${src}"
185185
done

0 commit comments

Comments
 (0)