Skip to content

Commit

Permalink
scripts: Fixups for nounset
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Levand <geoff@infradead.org>
  • Loading branch information
glevand committed Jun 6, 2021
1 parent bdc8b76 commit b0ca652
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 133 deletions.
8 changes: 3 additions & 5 deletions scripts/audx-lib.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Send bug reports to: Geoff Levand <geoff@infradead.org>
#

dry_run=''

on_exit() {
local result=${1}

Expand Down Expand Up @@ -138,7 +136,7 @@ move_file() {
check_file 'source file' "${src}"

local echo_extra
if [[ ${dry_run} ]]; then
if [[ ${dry_run:-} ]]; then
echo_extra=' (dry run)'
else
echo_extra=''
Expand All @@ -150,7 +148,7 @@ move_file() {
echo "${FUNCNAME[0]}${echo_extra}: -> '${dest}'" >&2
fi

if [[ ! ${dry_run} ]]; then
if [[ ! ${dry_run:-} ]]; then
mkdir -p "${dest%/*}"
mv --no-clobber "${src}" "${dest}"
fi
Expand Down Expand Up @@ -566,7 +564,7 @@ metaflac_retag() {
echo "${FUNCNAME[0]}: file: '${file}'" >&2
echo "${FUNCNAME[0]}: ${tag_name}: '${old_tag}' => '${tag_data}'" >&2

if [[ ! ${dry_run} ]]; then
if [[ ! ${dry_run:-} ]]; then
${metaflac} --preserve-modtime --remove-tag="${tag_name}" --set-tag="${tag_name}=${tag_data}" "${file}"
fi
}
Expand Down
14 changes: 6 additions & 8 deletions scripts/check-vfat-names.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ process_opts() {
local short_opts="d:chvg"
local long_opts="vfat-dir:,clean-names,help,verbose,debug"

vfat_dir=''
clean_names=''
usage=''
verbose=''
debug=''

local opts
opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${script_name}" -- "$@")

Expand Down Expand Up @@ -126,8 +120,6 @@ start_time="$(date +%Y.%m.%d-%H.%M.%S)"

SCRIPTS_TOP=${SCRIPTS_TOP:-"$(cd "${BASH_SOURCE%/*}" && pwd)"}

tmp_dir=''

trap "on_exit 'Failed'" EXIT
trap 'on_err ${FUNCNAME[0]:-main} ${LINENO} ${?}' ERR
trap 'on_err SIGUSR1 ? 3' SIGUSR1
Expand All @@ -138,6 +130,12 @@ set -o nounset

source "${SCRIPTS_TOP}/audx-lib.sh"

vfat_dir=''
clean_names=''
usage=''
verbose=''
debug=''

process_opts "${@}"

if [[ -f "${HOME}/.audx.conf" ]]; then
Expand Down
26 changes: 12 additions & 14 deletions scripts/flac-add-tracktotal.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ usage() {
echo "${script_name} - Add FLAC tracktotal metadata tags."
echo "Usage: ${script_name} [flags] top-dir"
echo "Option flags:"
echo " -d --dry-run - Dry run, don't modify files."
echo " -h --help - Show this help and exit."
echo " -v --verbose - Verbose execution."
echo " -g --debug - Extra verbose execution."
echo " -d --dry-run - Dry run, don't modify files."
echo "Info:"
echo " ${script_name} (@PACKAGE_NAME@) version @PACKAGE_VERSION@"
echo " @PACKAGE_URL@"
Expand All @@ -22,13 +22,8 @@ usage() {
}

process_opts() {
local short_opts="dhvg"
local long_opts="dry-run,help,verbose,debug"

dry_run=''
usage=''
verbose=''
debug=''
local short_opts="hvgd"
local long_opts="help,verbose,debug,dry-run"

local opts
opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${script_name}" -- "$@")
Expand All @@ -38,10 +33,6 @@ process_opts() {
while true ; do
# echo "${FUNCNAME[0]}: (${#}) '${*}'"
case "${1}" in
-d | --dry-run)
dry_run=1
shift
;;
-h | --help)
usage=1
shift
Expand All @@ -56,6 +47,10 @@ process_opts() {
set -x
shift
;;
-d | --dry-run)
dry_run=1
shift
;;
--)
shift
top_dir="${1:-}"
Expand Down Expand Up @@ -111,8 +106,6 @@ start_time="$(date +%Y.%m.%d-%H.%M.%S)"

SCRIPTS_TOP=${SCRIPTS_TOP:-"$(cd "${BASH_SOURCE%/*}" && pwd)"}

tmp_dir=''

trap "on_exit 'Failed'" EXIT
trap 'on_err ${FUNCNAME[0]:-main} ${LINENO} ${?}' ERR
trap 'on_err SIGUSR1 ? 3' SIGUSR1
Expand All @@ -123,6 +116,11 @@ set -o nounset

source "${SCRIPTS_TOP}/audx-lib.sh"

usage=''
verbose=''
debug=''
dry_run=''

process_opts "${@}"

if [[ -f "${HOME}/.audx.conf" ]]; then
Expand Down
26 changes: 12 additions & 14 deletions scripts/flac-clean-tags.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ usage() {
echo "${script_name} - Clean FLAC metadata tags using standard rules."
echo "Usage: ${script_name} [flags] top-dir"
echo "Option flags:"
echo " -d --dry-run - Dry run, don't modify files."
echo " -h --help - Show this help and exit."
echo " -v --verbose - Verbose execution."
echo " -g --debug - Extra verbose execution."
echo " -d --dry-run - Dry run, don't modify files."
echo "Info:"
echo " ${script_name} (@PACKAGE_NAME@) version @PACKAGE_VERSION@"
echo " @PACKAGE_URL@"
Expand All @@ -22,13 +22,8 @@ usage() {
}

process_opts() {
local short_opts="dhvg"
local long_opts="dry-run,help,verbose,debug"

dry_run=''
usage=''
verbose=''
debug=''
local short_opts="hvgd"
local long_opts="help,verbose,debug,dry-run"

local opts
opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${script_name}" -- "$@")
Expand All @@ -38,10 +33,6 @@ process_opts() {
while true ; do
# echo "${FUNCNAME[0]}: (${#}) '${*}'"
case "${1}" in
-d | --dry-run)
dry_run=1
shift
;;
-h | --help)
usage=1
shift
Expand All @@ -56,6 +47,10 @@ process_opts() {
set -x
shift
;;
-d | --dry-run)
dry_run=1
shift
;;
--)
shift
top_dir="${1:-}"
Expand Down Expand Up @@ -144,8 +139,6 @@ start_time="$(date +%Y.%m.%d-%H.%M.%S)"

SCRIPTS_TOP=${SCRIPTS_TOP:-"$(cd "${BASH_SOURCE%/*}" && pwd)"}

tmp_dir=''

trap "on_exit 'Failed'" EXIT
trap 'on_err ${FUNCNAME[0]:-main} ${LINENO} ${?}' ERR
trap 'on_err SIGUSR1 ? 3' SIGUSR1
Expand All @@ -156,6 +149,11 @@ set -o nounset

source "${SCRIPTS_TOP}/audx-lib.sh"

usage=''
verbose=''
debug=''
dry_run=''

process_opts "${@}"

if [[ -f "${HOME}/.audx.conf" ]]; then
Expand Down
28 changes: 13 additions & 15 deletions scripts/flac-meta-rename.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ usage() {
echo "Usage: ${script_name} [flags] top-dir"
echo "Option flags:"
echo " -a --various - Use 'Various Artists' logic."
echo " -d --dry-run - Dry run, don't rename files."
echo " -h --help - Show this help and exit."
echo " -v --verbose - Verbose execution."
echo " -g --debug - Extra verbose execution."
echo " -d --dry-run - Dry run, don't rename files."
echo "Info:"
echo " ${script_name} (@PACKAGE_NAME@) version @PACKAGE_VERSION@"
echo " @PACKAGE_URL@"
Expand All @@ -23,14 +23,8 @@ usage() {
}

process_opts() {
local short_opts="adhvg"
local long_opts="various,dry-run,help,verbose,debug"

various=''
dry_run=''
usage=''
verbose=''
debug=''
local short_opts="ahvgd"
local long_opts="various,help,verbose,debug,dry-run"

local opts
opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${script_name}" -- "$@")
Expand All @@ -44,10 +38,6 @@ process_opts() {
various=1
shift
;;
-d | --dry-run)
dry_run=1
shift
;;
-h | --help)
usage=1
shift
Expand All @@ -62,6 +52,10 @@ process_opts() {
set -x
shift
;;
-d | --dry-run)
dry_run=1
shift
;;
--)
shift
top_dir="${1:-}"
Expand Down Expand Up @@ -89,8 +83,6 @@ start_time="$(date +%Y.%m.%d-%H.%M.%S)"

SCRIPTS_TOP=${SCRIPTS_TOP:-"$(cd "${BASH_SOURCE%/*}" && pwd)"}

tmp_dir=''

trap "on_exit 'Failed'" EXIT
trap 'on_err ${FUNCNAME[0]:-main} ${LINENO} ${?}' ERR
trap 'on_err SIGUSR1 ? 3' SIGUSR1
Expand All @@ -101,6 +93,12 @@ set -o nounset

source "${SCRIPTS_TOP}/audx-lib.sh"

various=''
dry_run=''
usage=''
verbose=''
debug=''

process_opts "${@}"

if [[ -f "${HOME}/.audx.conf" ]]; then
Expand Down
10 changes: 4 additions & 6 deletions scripts/flac-print-tags.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ process_opts() {
local short_opts="hvg"
local long_opts="help,verbose,debug"

usage=''
verbose=''
debug=''

local opts
opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${script_name}" -- "$@")

Expand Down Expand Up @@ -77,8 +73,6 @@ start_time="$(date +%Y.%m.%d-%H.%M.%S)"

SCRIPTS_TOP=${SCRIPTS_TOP:-"$(cd "${BASH_SOURCE%/*}" && pwd)"}

tmp_dir=''

trap "on_exit 'Failed'" EXIT
trap 'on_err ${FUNCNAME[0]:-main} ${LINENO} ${?}' ERR
trap 'on_err SIGUSR1 ? 3' SIGUSR1
Expand All @@ -89,6 +83,10 @@ set -o nounset

source "${SCRIPTS_TOP}/audx-lib.sh"

usage=''
verbose=''
debug=''

process_opts "${@}"

if [[ -f "${HOME}/.audx.conf" ]]; then
Expand Down
Loading

0 comments on commit b0ca652

Please sign in to comment.