Error handling, -- refactor, comments, etc.

This commit is contained in:
tosu 2023-03-06 00:01:37 +01:00
parent 7d7c8980ee
commit 3b3c4fdfc9
2 changed files with 6 additions and 7 deletions

View File

@ -38,10 +38,7 @@ $filter=
api-version=1.4-private api-version=1.4-private
EOM EOM
API_URL="$( API_URL="$(tr -d -- '\n' <<< "${API_URL//\{SPACE\}/ }")"
sed 's/{SPACE}/ /g' <<< "${API_URL}" |
tr -d '\n'
)"
mkdir -p "${OUTDIR}" || { mkdir -p "${OUTDIR}" || {
printf '\033[31m%s\033[m\n' 'Aborting' printf '\033[31m%s\033[m\n' 'Aborting'

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# Don't link mrsh to sh, since it does not allow line continuations
# in here-documents. Use dash, yash, bash, posh, ksh, mksh, zsh, pbosh
# Run entire script in subshell to prevent variable pollution # Run entire script in subshell to prevent variable pollution
( (
@ -17,7 +19,7 @@ IFS="
" "
POSIXLY_CORRECT='1' POSIXLY_CORRECT='1'
COMMANDS_='builtin unalias unset read printf command exit type . tr mkdir wc sed grep xargs ffmpeg jq wget' COMMANDS_='builtin unalias unset read printf command exit type . tr mkdir wc sed grep xargs ffmpeg jq wget'
\unset -f -- ${COMMANDS_} \unset -f -- ${COMMANDS_} 2>/dev/null
\unalias -- ${COMMANDS_} 2>/dev/null || true \unalias -- ${COMMANDS_} 2>/dev/null || true
command -v -- wget >/dev/null 2>&1 || { command -v -- wget >/dev/null 2>&1 || {
@ -45,7 +47,7 @@ OUTDIR='./videos'
read -r API_URL <<- EOM read -r API_URL <<- EOM
https://euwe-1.api.microsoftstream.com/api/videos?\ https://euwe-1.api.microsoftstream.com/api/videos?\
\$top=100\ \$top=3\
&\ &\
\$skip=0\ \$skip=0\
&\ &\
@ -75,7 +77,7 @@ EOM
API_URL="$( API_URL="$(
printf '%s' "${API_URL}" | printf '%s' "${API_URL}" |
tr -d '\t' tr -d -- '\t'
)" )"
mkdir -p -- "${OUTDIR}" || { mkdir -p -- "${OUTDIR}" || {