summaryrefslogtreecommitdiff
path: root/bin/stream
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-18 10:37:25 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-18 10:37:25 +0200
commitbff6b3ca2fc4f13592a52e3979161c8faa5b7bc0 (patch)
treed24b0122163ab5ed8415258825eb5da76b5fd783 /bin/stream
parent49cd10875fab0e69bfcf4b60f66261629ee96789 (diff)
Move generic functions (almost) to the top.
Diffstat (limited to 'bin/stream')
-rwxr-xr-xbin/stream48
1 files changed, 25 insertions, 23 deletions
diff --git a/bin/stream b/bin/stream
index c10901f..db1c100 100755
--- a/bin/stream
+++ b/bin/stream
@@ -7,10 +7,35 @@ set -eu
# TODO: Externalize to site-specific configfile
[ $# -gt 0 ] || set -- morla 5002 -- dvcam ../../content/icon_small.png
+##
+## generic functions
+##
exit1() {
echo >&2 "ERROR: $1"
exit 1
}
+# shellcheck disable=SC2048,SC2059
+echo_n() {
+ printf -- "$*"
+}
+# shellcheck disable=SC2048,SC2059
+printf_each() {
+ skel=$1; shift
+ for string in $*; do
+ printf -- "$skel" "$string"
+ done
+}
+uniqwords() {
+ echo_n "$@" | tr ' ' '\012' | sort -u
+}
+valuedargcount() {
+ nonempty=
+ while [ $# -gt 0 ]; do
+ [ -z "$1" ] || nonempty=$((nonempty+1))
+ shift
+ done
+ echo_n "$nonempty"
+}
while [ $# -gt 0 ]; do
case $1 in
@@ -130,29 +155,6 @@ fi
[ -n "$HEIGHTS_MPEG" ] || SPEED_VP8="$SPEED_VP8_ALONE"
[ -n "$HEIGHTS_WEBM" ] || SPEED_X264="$SPEED_X264_ALONE"
-# shellcheck disable=SC2048,SC2059
-echo_n() {
- printf -- "$*"
-}
-# shellcheck disable=SC2048,SC2059
-printf_each() {
- skel=$1; shift
- for string in $*; do
- printf -- "$skel" "$string"
- done
-}
-uniqwords() {
- echo_n "$@" | tr ' ' '\012' | sort -u
-}
-valuedargcount() {
- nonempty=
- while [ $# -gt 0 ]; do
- [ -z "$1" ] || nonempty=$((nonempty+1))
- shift
- done
- echo_n "$nonempty"
-}
-
HEIGHTS=$(uniqwords "$HEIGHTS_WEBM $HEIGHTS_MPEG")
[ -z "${SAVEDIR:-}" ] || SAVESTEM="${SAVEDIR:-}/$(date +%Y%m%d-%H%M%S)"