summaryrefslogtreecommitdiff
path: root/devscripts
diff options
context:
space:
mode:
authorDennis Fink2026-05-22 22:13:57 +0200
committerDennis Fink2026-05-22 22:13:57 +0200
commit70ca25e5b8cf72a30743170876f2565bc4c052fe (patch)
treecd7b0bbe20ee45c8ac9e4e1b0cd073446c92d03a /devscripts
parente6df883f8bb16e24705db1937a0d1d62cef4ae9d (diff)
downloadtranscode.sh-70ca25e5b8cf72a30743170876f2565bc4c052fe.tar.gz
transcode.sh-70ca25e5b8cf72a30743170876f2565bc4c052fe.zip
style(shell): use function keyword consistently
Add the function keyword to shell function definitions across the main script, developer scripts, and bash completion file. This makes function declarations visually consistent throughout the project and easier to scan without changing behavior.
Diffstat (limited to 'devscripts')
-rwxr-xr-xdevscripts/generate-testfile.sh36
-rwxr-xr-xdevscripts/release.sh50
2 files changed, 43 insertions, 43 deletions
diff --git a/devscripts/generate-testfile.sh b/devscripts/generate-testfile.sh
index e8bcbe8..fab91cd 100755
--- a/devscripts/generate-testfile.sh
+++ b/devscripts/generate-testfile.sh
@@ -125,7 +125,7 @@ readonly EXIT_OK EXIT_RUNTIME_FAILURE EXIT_USAGE_ERROR EXIT_CONFIG_ERROR EXIT_MI
# OUTPUT HELPERS
###############################################################################
-emit() {
+function emit() {
local prefix="$1"
local color="$2"
shift 2
@@ -151,29 +151,29 @@ emit() {
printf "\n"
}
-error() {
+function error() {
emit "==> ERROR:" "$RED" "$@" >&2
}
-msg() {
+function msg() {
if [[ $QUIET -eq 0 ]]; then
emit "==>" "$GREEN" "$@"
fi
}
-warn() {
+function warn() {
if [[ $QUIET -eq 0 ]]; then
emit "==>" "$YELLOW" "$@"
fi
}
-verbose() {
+function verbose() {
if [[ $VERBOSE -eq 1 && $QUIET -eq 0 ]]; then
emit "==>" "$BLUE" "$@"
fi
}
-debug() {
+function debug() {
if [[ $DEBUG -eq 1 ]]; then
emit "==> DEBUG:" "$MAGENTA" "$@"
fi
@@ -183,7 +183,7 @@ debug() {
# HELP AND VERSION OUTPUT
###############################################################################
-print_help() {
+function print_help() {
printf "${BOLD}${MAGENTA}%s${ALL_OFF} - ${BOLD}${CYAN}%s${ALL_OFF} - ${BOLD}%s${ALL_OFF}
${BOLD}${BLUE}Usage:${ALL_OFF} ${BOLD}${MAGENTA}%s${ALL_OFF} ${BOLD}${YELLOW}[OPTION]...${ALL_OFF} ${BOLD}${GREEN}[OUTPUT]${ALL_OFF}
@@ -221,7 +221,7 @@ ${BOLD}${BLUE}Examples:${ALL_OFF}
"$SCRIPTNAME" "$SCRIPTNAME" "$SCRIPTNAME" "$SCRIPTNAME"
}
-print_version() {
+function print_version() {
printf "${RED}${BOLD}Scriptname:${ALL_OFF} %s
${GREEN}${BOLD}Version:${ALL_OFF} %s
${YELLOW}${BOLD}Description:${ALL_OFF} %s
@@ -272,7 +272,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" \
# disabled. If FORCE_COLOR is set, colors are always enabled.
###############################################################################
-setup_colors() {
+function setup_colors() {
if [[ "$ENABLE_COLOR" -eq 1 ]]; then
if tput setaf 0 >/dev/null 2>&1; then
debug "Setting colors via tput"
@@ -313,7 +313,7 @@ setup_colors() {
# GENERATION HELPERS
###############################################################################
-require_command() {
+function require_command() {
local command_name="$1"
command -v "$command_name" >/dev/null 2>&1 || {
@@ -322,28 +322,28 @@ require_command() {
}
}
-validate_resolution() {
+function validate_resolution() {
if [[ ! "$RESOLUTION" =~ ^[1-9][0-9]*x[1-9][0-9]*$ ]]; then
error "Resolution must use WIDTHxHEIGHT format:" "$RESOLUTION"
exit $EXIT_USAGE_ERROR
fi
}
-validate_length() {
+function validate_length() {
if [[ "$LENGTH" =~ ^- ]]; then
error "Length must be a positive ffmpeg duration:" "$LENGTH"
exit $EXIT_USAGE_ERROR
fi
}
-validate_frame_rate() {
+function validate_frame_rate() {
if [[ ! "$FRAME_RATE" =~ ^[1-9][0-9]*([.][0-9]+)?$ ]]; then
error "Frame rate must be a positive number:" "$FRAME_RATE"
exit $EXIT_USAGE_ERROR
fi
}
-extension_for_codec() {
+function extension_for_codec() {
case "$CODEC" in
libvpx | libvpx-vp9)
printf "webm"
@@ -357,7 +357,7 @@ extension_for_codec() {
esac
}
-sanitized_name_part() {
+function sanitized_name_part() {
local value="$1"
value="${value//\//-}"
value="${value//:/-}"
@@ -365,7 +365,7 @@ sanitized_name_part() {
printf "%s" "$value"
}
-default_output_path() {
+function default_output_path() {
local extension codec_part length_part
extension="$(extension_for_codec)"
codec_part="$(sanitized_name_part "$CODEC")"
@@ -374,13 +374,13 @@ default_output_path() {
printf "%s/%s-%s-%ss.%s" "$OUTPUT_DIR" "$codec_part" "$RESOLUTION" "$length_part" "$extension"
}
-print_command() {
+function print_command() {
local quoted_command
printf -v quoted_command '%q ' "${FFMPEG_COMMAND[@]}"
printf "%s\n" "${quoted_command% }"
}
-generate_test_file() {
+function generate_test_file() {
local output_file="$1"
if [[ -e "$output_file" && $OVERWRITE -eq 0 ]]; then
diff --git a/devscripts/release.sh b/devscripts/release.sh
index 0fda106..8ef1bd0 100755
--- a/devscripts/release.sh
+++ b/devscripts/release.sh
@@ -119,7 +119,7 @@ readonly EXIT_OK EXIT_RUNTIME_FAILURE EXIT_USAGE_ERROR EXIT_CONFIG_ERROR EXIT_MI
# OUTPUT HELPERS
###############################################################################
-emit() {
+function emit() {
local prefix="$1"
local color="$2"
shift 2
@@ -145,29 +145,29 @@ emit() {
printf "\n"
}
-error() {
+function error() {
emit "==> ERROR:" "$RED" "$@" >&2
}
-msg() {
+function msg() {
if [[ $QUIET -eq 0 ]]; then
emit "==>" "$GREEN" "$@"
fi
}
-warn() {
+function warn() {
if [[ $QUIET -eq 0 ]]; then
emit "==>" "$YELLOW" "$@"
fi
}
-verbose() {
+function verbose() {
if [[ $VERBOSE -eq 1 && $QUIET -eq 0 ]]; then
emit "==>" "$BLUE" "$@"
fi
}
-debug() {
+function debug() {
if [[ $DEBUG -eq 1 ]]; then
emit "==> DEBUG:" "$MAGENTA" "$@"
fi
@@ -177,7 +177,7 @@ debug() {
# HELP AND VERSION OUTPUT
###############################################################################
-print_help() {
+function print_help() {
printf "${BOLD}${MAGENTA}%s${ALL_OFF} - ${BOLD}${CYAN}%s${ALL_OFF} - ${BOLD}%s${ALL_OFF}
${BOLD}${BLUE}Usage:${ALL_OFF} ${BOLD}${MAGENTA}%s${ALL_OFF} ${BOLD}${YELLOW}[OPTION]...${ALL_OFF} ${BOLD}${GREEN}COMMAND VERSION${ALL_OFF}
@@ -213,7 +213,7 @@ ${BOLD}${BLUE}Notes:${ALL_OFF}
"$SCRIPTNAME" "$SCRIPTNAME" "$SCRIPTNAME" "$DIST_DIR"
}
-print_version() {
+function print_version() {
printf "${RED}${BOLD}Scriptname:${ALL_OFF} %s
${GREEN}${BOLD}Version:${ALL_OFF} %s
${YELLOW}${BOLD}Description:${ALL_OFF} %s
@@ -264,7 +264,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" \
# disabled. If FORCE_COLOR is set, colors are always enabled.
###############################################################################
-setup_colors() {
+function setup_colors() {
if [[ "$ENABLE_COLOR" -eq 1 ]]; then
if tput setaf 0 >/dev/null 2>&1; then
debug "Setting colors via tput"
@@ -305,7 +305,7 @@ setup_colors() {
# RELEASE HELPERS
###############################################################################
-require_command() {
+function require_command() {
local command_name="$1"
command -v "$command_name" >/dev/null 2>&1 || {
@@ -314,7 +314,7 @@ require_command() {
}
}
-require_release_dependencies() {
+function require_release_dependencies() {
require_command date
require_command git
require_command grep
@@ -322,7 +322,7 @@ require_release_dependencies() {
require_command tar
}
-validate_version() {
+function validate_version() {
local version="$1"
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
@@ -331,7 +331,7 @@ validate_version() {
fi
}
-require_project_files() {
+function require_project_files() {
local file
for file in "$MAIN_SCRIPT" "$MAN_PAGE" "$README_FILE"; do
@@ -342,7 +342,7 @@ require_project_files() {
done
}
-require_clean_worktree() {
+function require_clean_worktree() {
if ! git diff --quiet --; then
error "working tree has unstaged changes"
exit $EXIT_RUNTIME_FAILURE
@@ -354,7 +354,7 @@ require_clean_worktree() {
fi
}
-require_tag_absent() {
+function require_tag_absent() {
local version="$1"
if git rev-parse -q --verify "refs/tags/v$version" >/dev/null; then
@@ -365,7 +365,7 @@ require_tag_absent() {
# Replace a literal release metadata pattern in a file.
# Keep all sed -i portability handling in this one function.
-replace_literal() {
+function replace_literal() {
local file="$1"
local pattern="$2"
local replacement="$3"
@@ -401,7 +401,7 @@ replace_literal() {
fi
}
-update_version_and_date() {
+function update_version_and_date() {
local version="$1"
local revision_date="$2"
@@ -441,7 +441,7 @@ update_version_and_date() {
fi
}
-verify_release_metadata() {
+function verify_release_metadata() {
local version="$1"
local revision_date="$2"
@@ -478,16 +478,16 @@ verify_release_metadata() {
}
}
-read_revision_date() {
+function read_revision_date() {
sed -n -E 's/^readonly DATE_OF_REVISION=([0-9]{4}-[0-9]{2}-[0-9]{2})$/\1/p' "$MAIN_SCRIPT"
}
-show_release_diff() {
+function show_release_diff() {
msg "Release metadata diff:"
git diff -- "$MAIN_SCRIPT" "$MAN_PAGE" "$README_FILE"
}
-commit_release() {
+function commit_release() {
local version="$1"
if [[ $DRY_RUN -eq 1 ]]; then
@@ -500,7 +500,7 @@ commit_release() {
git commit -m "chore(release): prepare $version"
}
-tag_release() {
+function tag_release() {
local version="$1"
if [[ $DRY_RUN -eq 1 ]]; then
@@ -512,7 +512,7 @@ tag_release() {
git tag -a "v$version" -m "Release v$version"
}
-create_archive() {
+function create_archive() {
local version="$1"
local archive_name="$PROJECT_NAME-$version.tar.gz"
local archive_path="$DIST_DIR/$archive_name"
@@ -539,7 +539,7 @@ create_archive() {
fi
}
-prepare_release() {
+function prepare_release() {
local version="$1"
local revision_date
revision_date="$(date +%F)"
@@ -557,7 +557,7 @@ prepare_release() {
show_release_diff
}
-release() {
+function release() {
local version="$1"
local revision_date