remove unnecessary tmpdir setting

This commit is contained in:
yosh 2023-11-08 19:15:06 -05:00
parent e663630d39
commit 626630a4c1
1 changed files with 9 additions and 21 deletions

View File

@ -33,18 +33,6 @@ warn() {
fi
}
_tempdir() {
set +u
[ -n "$TMPDIR" ] || \
{ [ -n "$TEMP" ] && TMPDIR="$TEMP"; } || \
{ [ -n "$TMP" ] && TMPDIR="$TMP"; } || \
{ [ -d "/tmp" ] && TMPDIR="/tmp"; } || \
{ [ -d "/var/tmp" ] && TMPDIR="/var/tmp"; } || \
{ [ -d "/usr/tmp" ] && TMPDIR="/usr/tmp"; } || \
TMPDIR="$PWD"
set -u
}
checkupdate() {
errecho "you are running version ${GREEN}${VERSION}"
errecho "until I learn if forgejo has an equivalent for github's latest release download shenanigans just check to see if this version matches the latest release"
@ -115,7 +103,7 @@ process_file() {
# export pic if we're keeping it
if [ -z "$RMPIC" ]; then
pic="$TMPDIR/${bname%.*}_IMG"
pic="$(mktemp "${bname%.*}XXXX")"
metaflac --export-picture-to="$pic" "$infile"
fi
@ -217,7 +205,6 @@ TYPE=opus
BITRATE=128
THREADS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null)" # hopefully portable enough to not be an issue
[ $? -ne 0 ] && warn 'unable to find number of cores! defaulting to 1 thread unless otherwise specified...' && THREADS=1
_tempdir # set temp dir
while getopts :huvVid3peb:l:k:r:j: OPT; do
case "$OPT" in
@ -241,24 +228,25 @@ done
shift "$((OPTIND - 1))"
[ -n "$REALLYVERBOSE" ] && set -x
command -v metaflac 1>/dev/null 2>&1 || fail 'flac tools are not installed! (metaflac)'
if [ "$TYPE" = "opus" ]; then command -v opusenc 1>/dev/null 2>&1 || fail 'opus-tools is not installed! (opusenc)'
else command -v lame 1>/dev/null 2>&1 || fail 'lame is not installed! (lame)'
if [ "$TYPE" = "opus" ]; then
command -v opusenc 1>/dev/null 2>&1 || fail 'opus-tools is not installed! (opusenc)'
else
command -v lame 1>/dev/null 2>&1 || fail 'lame is not installed! (lame)'
fi
[ -n "$RMENCTAG" ] && { command -v opustags 1>/dev/null 2>&1 || fail 'opustags is not installed! this is required for -e (opustags)' ; }
# if no arg provided, use cwd
[ "$#" -eq 0 ] && set -- .
# this script assumes you aren't using newlines in path names
# I do not want to change it to account for this
# you should never put newlines in paths
# it is a very bad idea for many programs
# if no arg provided, cwd
[ "$#" -eq 0 ] && set -- .
FLACFILES="$(find "$@" -type f -name "*.[fF][lL][aA][cC]")"
[ -z "$FLACFILES" ] && fail 'no flac files found!'
# make a fifo/fd for parallel stuff
mk_parallel_fd() {
fifo_para="$(mktemp -u "$TMPDIR/flacconvXXXX")"
fifo_para="$(mktemp -u -t "flacconv.XXXX")"
mkfifo "$fifo_para"
exec 9<>"$fifo_para"
rm -f "$fifo_para"