Minor changes to satisfy shellcheck

This commit is contained in:
Nathaniel Landau
2016-02-09 17:18:26 -05:00
parent 321b0e3bb3
commit 4f33a18cb1
2 changed files with 36 additions and 36 deletions

View File

@@ -198,7 +198,7 @@ function mainScript() {
extension="$(echo "${extension}" | tr '[:upper:]' '[:lower:]')" # Lowercase the extension if needed
# See if the extension is in the specified extension mappings
if [[ ! "${videoTypes[*]}" =~ "${extension}" ]] && [[ ! "${audioTypes[*]}" =~ "${extension}" ]]; then
if [[ ! "${videoTypes[*]}" =~ ${extension} ]] && [[ ! "${audioTypes[*]}" =~ ${extension} ]]; then
error "The extension of '${extension} ' was not recognized."
die "We don't know what to do with ${fileToTest}."
fi
@@ -207,7 +207,7 @@ function mainScript() {
function convertToFormat() {
# Do things on video files
if [[ "${videoTypes[*]}" =~ "${file##*.}" ]]; then
if [[ "${videoTypes[*]}" =~ ${file##*.} ]]; then
# if you wanted a default target format for a specific input format,
# you would put it here.
# Set the default video conversion format to mp4
@@ -218,7 +218,7 @@ function mainScript() {
fi
# Do things on audio files
if [[ "${audioTypes[*]}" =~ "${file##*.}" ]]; then
if [[ "${audioTypes[*]}" =~ ${file##*.} ]]; then
# Ensure a user sets an output format since we don't have a default.
if [[ -z ${userOutput} ]]; then
@@ -309,11 +309,11 @@ function mainScript() {
fi
# Increase loop count
ii=$[$ii+1]
ii=$((ii+1))
done
# Error Handling for video files
if [[ "${videoTypes[*]}" =~ "${file##*.}" ]]; then
if [[ "${videoTypes[*]}" =~ ${file##*.} ]]; then
if [ "${videoFoundFlag}" = "false" ]; then
warning "Missing video stream for '${file}'."
seek_confirmation "Inspect the file with ffprobe?"
@@ -328,7 +328,7 @@ function mainScript() {
fi
# Error Handling for audio files
if [[ "${audioTypes[*]}" =~ "${file##*.}" ]]; then
if [[ "${audioTypes[*]}" =~ ${file##*.} ]]; then
if [ "${audioFoundFlag}" = "false" ]; then
warning "Missing audio stream for '${file}'."
seek_confirmation "Inspect the file with ffprobe?"
@@ -352,14 +352,14 @@ function mainScript() {
################################################################
# Pick the best aac audio encoder
if $(ffmpeg -version | grep enable-libfdk-aac >/dev/null); then
if ffmpeg -version | grep enable-libfdk-aac >/dev/null; then
aacEncoder="libfdk_aac"
else
aacencoder="libfaac"
aacEncoder="libfaac"
fi
supportedAudioCodecs=(aac ac3 eac3)
if [[ "${supportedAudioCodecs[*]}" =~ "${audioCodec}" ]]; then
if [[ "${supportedAudioCodecs[*]}" =~ ${audioCodec} ]]; then
videoAudioCommand="-c:a copy"
else
videoAudioCommand="-c:a ${aacEncoder} -b:a 160k"
@@ -435,7 +435,7 @@ function mainScript() {
userWidth=$(echo ${videoSize} | cut -f1 -dx)
userHeight=$(echo ${videoSize} | cut -f2 -dx)
if [ "${userWidth}" -gt "${videoWidth}" ] || [ "${userHeight}" -gt "${videoHeight}" ]; then
seek_confirmation "Upscale "${file}" to "${videoSize}"? It is already "${videoWidth}"x"${videoHeight}"."
seek_confirmation "Upscale ${file} to ${videoSize}? It is already ${videoWidth}x${videoHeight}."
if is_not_confirmed; then
continue
fi
@@ -450,7 +450,7 @@ function mainScript() {
# ####################################
if is_not_empty "${height}"; then
if [ "${height}" -gt "${videoHeight}" ]; then
seek_confirmation "Upscale "${file}" to height "${height}"? It is already "${videoWidth}"x"${videoHeight}"."
seek_confirmation "Upscale ${file} to height ${height}? It is already ${videoWidth}x${videoHeight}."
if is_not_confirmed; then
continue
fi
@@ -459,7 +459,7 @@ function mainScript() {
fi
if is_not_empty "${width}"; then
if [ "${width}" -gt "${videoWidth}" ]; then
seek_confirmation "Upscale "${file}" to width "${width}"? It is already "${videoWidth}"x"${videoHeight}"."
seek_confirmation "Upscale ${file} to width ${width}? It is already ${videoWidth}x${videoHeight}."
if is_not_confirmed; then
continue
fi
@@ -478,7 +478,7 @@ function mainScript() {
# Don't convert to self if no other options set
if [[ -z ${height} && -z ${width} && -z ${videoSize} && ${downsize720} == "0" && "${outputFormat}" == "${file##*.}" ]]; then
error "Can't convert a '"${file##*.}"' file to itself. Skipping ${file}"
error "Can't convert a '${file##*.}' file to itself. Skipping ${file}"
continue
fi
}
@@ -519,7 +519,7 @@ function mainScript() {
elif [[ "${userOutput,,}" == "aac" || "${userOutput,,}" == "m4a" ]]; then
outputFormat="m4a"
# Pick the best aac audio encoder
if $(ffmpeg -version | grep enable-libfdk-aac >/dev/null); then
if ffmpeg -version | grep enable-libfdk-aac >/dev/null; then
# set variable bit rate to '5', the highest unless we are doing spoken word
if ${spokenWord}; then
aacEncoder='libfdk_aac'
@@ -537,7 +537,7 @@ function mainScript() {
fi
elif [[ "${userOutput,,}" == "mp3" ]]; then
# Can we convert to mp3? Do we have an ffmpeg encoder?
if $(ffmpeg -version | grep enable-libmp3lame >/dev/null); then
if ffmpeg -version | grep enable-libmp3lame >/dev/null; then
mp3Encoder='libmp3lame'
# else
# warning "No workable ffmpeg mp3 encoder. Skipping ${f}..."
@@ -562,7 +562,7 @@ function mainScript() {
# need high fidelity or stereo so we make them mono and low bit-rate.
# Pick the best aac audio encoder
if $(ffmpeg -version | grep enable-libfdk-aac >/dev/null); then
if ffmpeg -version | grep enable-libfdk-aac >/dev/null; then
# set variable bit rate to '5', the highest
aacEncoder="libfdk_aac ${monoConversion} -f m4a"
else
@@ -662,17 +662,17 @@ function mainScript() {
verbose "Running XLD commands for audio. No FFMPEG."
# Respect --safe flag.
if [[ "${safeRun}" == "1" ]]; then
notice "xld -o "${output}" ${audioConvertCommand} "${file}""
notice "xld -o "${output} ${audioConvertCommand} ${file}
else
verbose "xld -o "${output}" ${audioConvertCommand} "${file}""
xld -o "${output}" ${audioConvertCommand} "${file}"
verbose "xld -o ${output} ${audioConvertCommand} ${file}"
xld -o "${output}" "${audioConvertCommand}" "${file}"
fi
else # Use ffmpeg when XLD is set to 0
# Respect --safe flag.
if [[ "${safeRun}" == "1" ]]; then
notice "ffmpeg -i "${file}" ${videoResize} ${videoCommand} ${videoAudioCommand} ${audioConvertCommand} "${output}" ${ffquiet}"
notice "ffmpeg -i ${file} ${videoResize} ${videoCommand} ${videoAudioCommand} ${audioConvertCommand} ${output} ${ffquiet}"
else
verbose "ffmpeg -i "${file}" ${videoResize} ${videoCommand} ${videoAudioCommand} ${audioConvertCommand} "${output}" ${ffquiet}"
verbose "ffmpeg -i ${file} ${videoResize} ${videoCommand} ${videoAudioCommand} ${audioConvertCommand} ${output} ${ffquiet}"
ffmpeg -i "${file}" ${videoResize} ${videoCommand} ${videoAudioCommand} ${audioConvertCommand} "${output}" ${ffquiet}
fi
fi

View File

@@ -39,10 +39,10 @@ function safeExit() {
# Outputs each line in a variable named $result
# ------------------------------------------------------
function readFile() {
unset ${result}
unset "${result}"
while read result
do
echo ${result}
echo "${result}"
done < "$1"
}
@@ -220,14 +220,14 @@ function is_not_empty() {
# ------------------------------------------------------
function type_exists() {
if [ $(type -P "$1") ]; then
if [ "$(type -P "$1")" ]; then
return 0
fi
return 1
}
function type_not_exists() {
if [ ! $(type -P "$1") ]; then
if [ ! "$(type -P "$1")" ]; then
return 0
fi
return 1
@@ -334,7 +334,7 @@ function unmountDrive() {
function help () {
echo "" 1>&2
input " ${@}" 1>&2
input " $@" 1>&2
if [ -n "${usage}" ]; then # print usage information if available
echo " ${usage}" 1>&2
fi
@@ -401,9 +401,9 @@ function pauseScript() {
function in_array() {
# Determine if a value is in an array.
# Usage: in_array [VALUE] [ARRAY]
local value=$1; shift
for item in "$@"; do
[[ $item == $value ]] && return 0
local value="$1"; shift
for arrayItem in "$@"; do
[[ "${arrayItem}" == "${value}" ]] && return 0
done
return 1
}
@@ -483,7 +483,7 @@ squeeze_lines() {
# -----------------------------------
progressBar() {
if [[ ${quiet} = "true" ]] || [ ${quiet} == "1" ]; then
if [[ "${quiet}" = "true" ]] || [ "${quiet}" == "1" ]; then
return
fi
@@ -495,7 +495,7 @@ progressBar() {
if ${verbose}; then return; fi
# Reset the count
if [ -z ${progressBarProgress} ]; then
if [ -z "${progressBarProgress}" ]; then
progressBarProgress=0
fi
@@ -508,11 +508,11 @@ progressBar() {
tput civis
trap 'tput cnorm; exit 1' SIGINT
if [ ! ${progressBarProgress} -eq $(( $1 - 1 )) ]; then
if [ ! "${progressBarProgress}" -eq $(( $1 - 1 )) ]; then
# Compute the percentage.
perc=$(( ${progressBarProgress} * 100 / $1 ))
perc=$(( progressBarProgress * 100 / $1 ))
# Compute the number of blocks to represent the percentage.
num=$(( ${progressBarProgress} * $width / $1 ))
num=$(( progressBarProgress * width / $1 ))
# Create the progress bar string.
bar=
if [ ${num} -gt 0 ]; then
@@ -521,7 +521,7 @@ progressBar() {
# Print the progress bar.
progressBarLine=$(printf "%s [%-${width}s] (%d%%)" "Running Process" "${bar}" "${perc}")
echo -en "${progressBarLine}\r"
progressBarProgress=$[${progressBarProgress}+1]
progressBarProgress=$(( progressBarProgress + 1 ))
else
# Clear the progress bar when complete
echo -ne "${width}%\033[0K\r"
@@ -552,7 +552,7 @@ urlencode() {
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
[a-zA-Z0-9.~_-]) printf "%s" "$c" ;;
*) printf '%%%02X' "'$c"
esac
done