scripts: Reformat with tabs and more consistent style

master
Pierre Neidhardt 2014-11-12 16:15:39 +01:00
parent a248dd1c19
commit 9857145fb1
74 changed files with 1592 additions and 1650 deletions

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp()
{
_usage () {
cat <<EOF
Usage: ${1##*/} MODE
@ -24,27 +23,22 @@ OPT_PROCESS=false
while getopts ":hef" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
e)
SAMPLE="-ss 60 -t 60"
OPT_PROCESS=true ;;
f)
OPT_PROCESS=true ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
:)
echo "Missing argument."
_printhelp "$0"
exit 1 ;;
esac
done
shift $(($OPTIND - 1))
if ! $OPT_PROCESS; then
_printhelp "$0"
_usage "$0"
exit
fi
@ -53,8 +47,7 @@ if ! command -v ffmpeg >/dev/null 2>&1; then
exit 1
fi
_transcode ()
{
_transcode () {
## You can choose here to process all files at the same time. Useful if you
## need to remux streams or to concatenate.
# ffmpeg -i ###FILELIST \

View File

@ -4,8 +4,7 @@
UPSTREAM_SOURCE="srcdir"
## End of user config
_printhelp ()
{
_usage () {
cat <<EOF
Usage: ${1##*/} [OPTIONS] PACKAGES
@ -76,27 +75,41 @@ while getopts ":bcCfhis" opt; do
PACMAN_OPT=""
OPT_FORCE=true ;;
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
i)
OPT_INSTALL=true ;;
s)
OPT_SOURCE=true ;;
?)
_printhelp "$0"
exit 1 ;;
:)
echo "Missing argument."
_printhelp "$0"
\?)
echo 'HO'
_usage "$0"
exit 1 ;;
esac
done
usage () {
cat<<EOF
Usage: ${1##*/} [OPTIONS] FILES
Options:
-h: Show this help.
EOF
}
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
usage "$0"
exit 1
fi
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
echo "Missing argument."
_printhelp "$0"
_usage "$0"
exit 1
fi
@ -122,8 +135,7 @@ fi
################################################################################
abs_pkgbuild ()
{
abs_pkgbuild () {
pacman -Si $1 >/dev/null 2>&1
if [ $? -eq 0 ] && $HAS_ABS && [ -d "$ABSROOT" ]; then
cp -r /var/abs/*/$1 .
@ -132,22 +144,19 @@ abs_pkgbuild ()
fi
}
abs_source ()
{
abs_source () {
(cd "$1" && \
mkdir -p "$UPSTREAM_SOURCE" && \
SRCDEST="$UPSTREAM_SOURCE" makepkg -o)
}
## TODO: unused function. Add 'build all deps from source' parameter?
abs_builddeps ()
{
abs_builddeps () {
DEPLIST=$(awk -F"'" '/^(make)?depends *= *\(/,/\)/ {for (n=2 ; n<NF; n++) res=res $n " "} END {gsub(/ +/, " ", res); print res}' PKGBUILD)
(cd .. && abs-wrapper $DEPLIST)
}
abs_buildmissing ()
{
abs_buildmissing () {
DEPLIST="$(makepkg -s 2>&1 | awk -F: '/target not found/ {print $3}')"
cd ..
while IFS= read -r p; do
@ -160,8 +169,7 @@ EOF
cd $1
}
abs_build ()
{
abs_build () {
(cd "$1" && \
mkdir -p "$UPSTREAM_SOURCE" && \
(makepkg -s || \
@ -169,23 +177,20 @@ abs_build ()
SRCDEST="$UPSTREAM_SOURCE" makepkg -r $MAKEPKG_OPT --nocheck --noconfirm)
}
abs_clean ()
{
abs_clean () {
(cd "$1" && \
echo "Removing src/ and pkg/ folders." && \
rm -rf "src" "pkg")
}
abs_mrproper ()
{
abs_mrproper () {
(cd "$1" && \
echo "Removing archives." && \
rm -v *.tar.gz *.tar.xz *.tar.bz *.tar.bz2 *.tgz *.txz *.tbz *.tbz2 2>/dev/null)
}
abs_install ()
{
abs_install () {
sudo sh -c '
(cd "$0" && pacman '$PACMAN_OPT' --noconfirm -U *.pkg.tar.xz)
for i; do

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp()
{
_usage () {
cat <<EOF
Usage: ${1##*/} [-m METHOD] [-v] FILES|FOLDERS
@ -29,7 +28,7 @@ OPT_SPLIT=false
while getopts ":him:sv" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
i)
OPTIONS="$OPTIONS --owner=root --group=root --numeric-owner" ;;
@ -42,8 +41,8 @@ while getopts ":him:sv" opt; do
OPT_SPLIT=true ;;
v)
OPTIONS="$OPTIONS --exclude-vcs" ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -52,7 +51,7 @@ done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi
@ -64,8 +63,7 @@ if ! command -v realpath >/dev/null 2>&1; then
exit 1
fi
_archive()
{
_archive () {
## Only one input entry: use it as base name for the archive.
if [ $# -eq 1 ]; then
REALPATH="$(realpath "$1")"

View File

@ -34,4 +34,3 @@ if ! command -v curl >/dev/null 2>&1; then
fi
$AGENT "$DOMAIN/man.cgi?query=$PAGE&apropos=0&sektion=$SECTION&manpath=$MANPATH&arch=default&format=ascii" | less

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp ()
{
_usage () {
cat<<EOF
Usage: ${1##*/} [OPTIONS] ISOFILE
@ -19,12 +18,12 @@ DRIVE=/dev/sr0
while getopts ":hd:" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
d)
DRIVE=/dev/$OPTARG ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -32,7 +31,7 @@ done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi

View File

@ -3,7 +3,7 @@
rawname=${0##*/}
rawname=${rawname#c}
usage() {
usage () {
cat <<EOF
Usage: ${1##*/}
@ -20,10 +20,10 @@ fi
## Check values.
case $rawname in
poweroff) ;;
reboot) ;;
halt) ;;
*)
poweroff) ;;
reboot) ;;
halt) ;;
*)
usage "$0"
exit ;;
esac

View File

@ -8,14 +8,12 @@ BEGIN {
}
## Some fields are surrounded by unwanted double quotes.
function remove_quotes(s)
{
function remove_quotes(s) {
gsub(/^"+|"+$/, "", s)
return s
}
function capitalize(s)
{
function capitalize(s) {
result = ""
while(match(s,/[ -]/))
{
@ -53,4 +51,3 @@ FNR==1 {
print ""
ind++
}

View File

@ -13,5 +13,3 @@ fi
curl -sA "Mozilla/5.0" "http://www.google.com/finance?q=$2$3" | \
awk -v value=$1 -F '<|>' '/^1 / {print value * substr($3, 1, index($3," "))}'

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp ()
{
_usage () {
cat<<EOF
Usage: ${1##*/} [OPTIONS] [FILES]
@ -30,14 +29,14 @@ while getopts ":fhin:" opt; do
f)
OPT_CUTFIRST=true ;;
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
i)
OPT_INPLACE="-i" ;;
n)
OPT_LINES=$OPTARG ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp ()
{
_usage () {
cat<<EOF
Usage: ${1##*/} [OPTIONS] FOLDERS
@ -24,12 +23,12 @@ while getopts ":fhw" opt; do
f)
opt_noclobber=false ;;
h)
_printhelp "$0"
_usage "$0"
exit 0 ;;
w)
opt_file=true ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -37,7 +36,7 @@ done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi
@ -70,4 +69,3 @@ for i ; do
cat
fi
done

View File

@ -18,12 +18,12 @@ else
fi
case "$ARG" in
*:*) SEP=':';;
*\;*) SEP=';';;
*/*) SEP='/';;
*,*) SEP=',';;
*\|*) SEP='|';;
*) SEP=':';;
*:*) SEP=':';;
*\;*) SEP=';';;
*/*) SEP='/';;
*,*) SEP=',';;
*\|*) SEP='|';;
*) SEP=':';;
esac
echo "$ARG" | awk -v RS=$SEP '1'

View File

@ -1,7 +1,6 @@
#!/bin/sh
check()
{
check() {
for i ; do
if ! command -v $i >/dev/null 2>&1; then
echo "'$i' not found in PATH. Exiting." >&2
@ -9,6 +8,7 @@ check()
fi
done
}
check emacs realpath
[ -f "$1" ] && node="$(realpath "$1")" || node="$1"

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp ()
{
_usage () {
cat<<EOF
Usage: ${1##*/} [OPTIONS] SCRIPT [ARGS...]
@ -22,15 +21,15 @@ while getopts :bc OPT; do
OPT_BYTE=true ;;
c)
OPT_CLEAN=true ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi

View File

@ -1,9 +1,8 @@
#!/usr/bin/env zsh
## zsh is needed for the password.
_printhelp ()
{
cat<<EOF
_usage () {
cat<<EOF
Usage: ${1##*/} [OPTIONS] FILES|FOLDERS
Wrapper around various archive extraction tools. The archives are recognized
@ -33,7 +32,7 @@ PASS=''
while getopts ":hfp" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
f)
OPT_DELAFTER=true ;;
@ -41,8 +40,8 @@ while getopts ":hfp" opt; do
echo -n "Password: "
read -s PASS
PASS="-p$PASS" ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -50,14 +49,13 @@ done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi
command -v atool >/dev/null 2>&1 && echo "You should use atool instead." && echo
_extract()
{
_extract () {
echo "[$1]"
case "$1" in
*/*) FOLDER="${1%/*}";;

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp()
{
_usage() {
cat<<EOF
Usage: ${0##*/} FOLDERS
@ -10,7 +9,7 @@ EOF
}
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
_printhelp
_usage
exit
fi

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp ()
{
_usage () {
cat<<EOF
Usage: ${1##*/} [OPTIONS] REPOS
@ -21,14 +20,14 @@ USER=ambrevar
while getopts ":hd:u:" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
d)
DOMAIN=$OPTARG ;;
u)
USER=$OPTARG ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -36,7 +35,7 @@ done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi

View File

@ -1,16 +1,11 @@
#!/bin/sh
_printhelp()
{
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
cat<<EOF
Usage: ${0##*/} FOLDERS
Sync all git repos found in FOLDERS.
EOF
}
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
_printhelp
exit
fi

View File

@ -52,4 +52,3 @@ else
rm -f "$ALSACONF"
echo "HDMI sound disabled"
fi

View File

@ -1,8 +1,6 @@
#!/bin/sh
################################################################################
## Home session initialization.
## 2013-06-14
################################################################################
SOURCEDIR="$HOME/personal/dataperso"
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
[ -z "$XDG_DATA_HOME" ] && XDG_DATA_HOME="$HOME/.local/share"

View File

@ -6,8 +6,7 @@
FUSEROOT="$HOME/fuse"
################################################################################
_mount ()
{
_mount () {
[ ! -f "$1" ] && return
DEVICE="$(cdemu status | awk 'NR>2 && $2==0 {print $1; found=1; exit} END {if(! found)print NR-2}')"
@ -66,8 +65,7 @@ _mount ()
}
_umount ()
{
_umount () {
[ ! -d "$1" ] && return
NODE="$(df | awk -v mount="$1" '$0 ~ mount {node=$1; gsub(/[^%]+% /, ""); if ($0 ~ mount){print node; exit}}')"
@ -83,8 +81,7 @@ _umount ()
fi
}
_printhelp ()
{
_usage () {
cat<<EOF
Usage: ${1##*/} FILES
${1##*/} -u FOLDERS
@ -104,12 +101,12 @@ OPT_UNMOUNT=false
while getopts ":hu" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
u)
OPT_UNMOUNT=true ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -117,12 +114,11 @@ done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi
check()
{
check () {
for i ; do
if ! command -v $i >/dev/null 2>&1; then
echo >&2 "'$i' not found in PATH. Exiting."

View File

@ -16,6 +16,6 @@ LSOFOUT="$(lsof|awk '{print $1}')"
while IFS= read -r i; do
echo -n "$i "
echo "$LSOFOUT" | grep -c "^$i"
done<<EOF
done<<EOF
$(echo "$LSOFOUT" | sort -u)
EOF

View File

@ -1,6 +1,6 @@
#!/bin/sh
if [ "$1" = "-h" ] || [ $# -lt 2 ]; then
_usage () {
cat <<EOF
${0##*/} FOLDERS DEST
@ -15,8 +15,7 @@ Options:
-f: Overwrite destination.
-r: Remove empty folders.
EOF
exit
fi
}
OPT_OVERWRITE=false
OPT_DELEMPTY=false
@ -24,21 +23,21 @@ OPT_DELEMPTY=false
while getopts ":fhr" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
f)
OPT_OVERWRITE=true ;;
r)
OPT_DELEMPTY=true ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi

View File

@ -4,19 +4,19 @@
## better off running the dhcpcd daemon with
## /etc/wpa_supplicant/wpa_supplicant.conf configured if needed. See
## dhcpcd-run-hooks(8).
##
## Deps: wpa_supplicant, ccrypt (optional)
##
## We need to use wpa_supplicant's unencrypted config file. We store it in a
## variable to keep it secure, but the 'wpa_supplicant' command requires a
## file. We cannot use a pipe for that, because in that case the config would be
## accessible unencrypted. So we need to use an internal path with a syntax like
## <(...) which is not specified by POSIX. Ksh, bash and Zsh can handle it.
##
## Use 'wpa_passphrase ESSID $PW >> /etc/wpa_supplicant.conf', where PW is a
## variable containing the password. You can set PW securely by using a shell
## built-in like 'read -s PW'.
##
## There is an Emacs plugin for editing crypted files directly. See 'man
## ccrypt'.
@ -25,8 +25,7 @@ TIMEOUT_LIMIT=500
USE_DHCP=0
USE_CRYPT=0
_printhelp ()
{
_usage () {
cat<<EOF
Usage: ${1##*/} [OPTIONS]
@ -44,7 +43,7 @@ EOF
while getopts ":cdht:w:" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
return 1 ;;
c)
USE_CRYPT=1 ;;
@ -54,8 +53,8 @@ while getopts ":cdht:w:" opt; do
TIMEOUT_LIMIT=$OPTARG ;;
w)
WSFILE="$OPTARG" ;;
?)
_printhelp "$0"
\?)
_usage "$0"
return 1 ;;
esac
done
@ -115,8 +114,8 @@ if [ "$OSTYPE" = "linux-gnu" ] ; then
[ $USE_DHCP -eq 1 ] && dhcpcd ${NET_INTERFACE}
else
## BSD
## Same comments as for Linux.
## BSD
## Same comments as for Linux.
pkill dhclient
ifconfig wlan0 up

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp()
{
_usage () {
cat <<EOF
Usage: ${1##*/} [OPTIONS] PACKAGES
@ -18,12 +17,12 @@ OPTION_SORT="cat"
while getopts ":hn" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
n)
OPTION_SORT="sort -h" ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -32,7 +31,7 @@ shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
echo "Missing argument."
_printhelp "$0"
_usage "$0"
exit 1
fi

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp()
{
_usage () {
cat <<EOF
Usage: ${1##*/} [-m|-e] [-q] FILE
@ -23,14 +22,14 @@ while getopts ":hmqe" opt; do
e)
OPTION_EXPLICIT="e" ;;
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
m)
OPTION_FOREIGN="m" ;;
q)
OPTION_LOCAL="-2" ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -39,7 +38,7 @@ shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
echo "Missing argument."
_printhelp "$0"
_usage "$0"
exit 1
fi
@ -57,4 +56,3 @@ rm -f "$PKGLIST" "$FILE"
## Zsh version.
# comm -3 ${OPTION_LOCAL} <(pacman -Qq${OPTION_FOREIGN}${OPTION_EXPLICIT} | sort) <(sort "$*")

View File

@ -106,7 +106,7 @@ while getopts ":ahnstV" opt; do
V)
version "$0"
exit ;;
?)
\?)
usage "$0"
exit 1 ;;
esac

View File

@ -9,8 +9,7 @@
# -dGraphicsAlphaBits=4
# -dMaxStripSize=8192
_printhelp ()
{
_usage () {
cat <<EOF
Usage: ${1##*/} [OPTIONS] PDFFILES
@ -45,14 +44,14 @@ while getopts ":cfhin" opt; do
f)
OPT_OVERWRITE=true ;;
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
i)
OPT_INPLACE=true ;;
n)
OPT_COMPRESSION="-dColorConversionStrategy=/LeaveColorUnchanged -dEncodeColorImages=false -dEncodeGrayImages=false -dEncodeMonoImages=false" ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -60,7 +59,7 @@ done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi

View File

@ -14,4 +14,3 @@ if [ ! -f "$1" ]; then
fi
gs -q -o "$2" -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 "$1"

View File

@ -19,12 +19,12 @@ fi
TEMPFILE="$(mktemp -u "$1.XXXXXX")"
case "$1" in
*/*) DIR1="${1%/*}" ;;
*) DIR1="." ;;
*/*) DIR1="${1%/*}" ;;
*) DIR1="." ;;
esac
case "$2" in
*/*) DIR2="${2%/*}" ;;
*) DIR2="." ;;
*/*) DIR2="${2%/*}" ;;
*) DIR2="." ;;
esac
if ! mv -n "$1" "$TEMPFILE"; then

View File

@ -1,7 +1,6 @@
#!/bin/sh
_printhelp ()
{
_usage () {
cat<<EOF
Usage: ${1##*/} [OPTIONS] SEARCH REPLACE [FILES]
@ -23,10 +22,10 @@ while getopts ":ih" opt; do
i)
OPT_INPLACE=-i ;;
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
@ -34,7 +33,7 @@ done
shift $(($OPTIND - 1))
if [ $# -lt 2 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi
@ -42,8 +41,7 @@ search="$1"
replace="$2"
shift 2
_replace()
{
_replace () {
## We cannot use gsub, otherwise regex substitutions could occur.
## Source: http://mywiki.wooledge.org/BashFAQ/021
awk -v s="$search" -v r="$replace" 'BEGIN {l=length(s)} {o="";while (i=index($0, s)) {o=o substr($0,1,i-1) r; $0=substr($0,i+l)} print o $0}' "$@"

View File

@ -16,8 +16,7 @@ BEGIN {
}
{
while (match ($0, begin))
{
while (match ($0, begin)) {
before = substr ($0, 1, RSTART-1)
$0 = substr($0, RSTART)
printf("%s", before)

View File

@ -32,8 +32,7 @@ BEGIN {
due=""
tags=""
for (i = 1; i <= NF; i++)
{
for (i = 1; i <= NF; i++) {
split($i, a, ":")
if (a[1] ~ "^description$")

View File

@ -23,4 +23,3 @@ $(find "." \( \
-iname '*.ape' -o \
-iname '*.mpc' \) )
EOF

View File

@ -2,8 +2,7 @@
OUTPUT_NAME="tc-video"
_printhelp()
{
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
cat <<EOF
Usage: ${1##*/} [FILES]
@ -13,10 +12,6 @@ to transcode FILES with some useful options and instructive help.
This script is meant to be easily editable to fit the user needs.
EOF
}
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
_printhelp "$0"
exit
fi

View File

@ -2,8 +2,7 @@
## TODO: handle srt encoding?
_printhelp()
{
_usage () {
cat <<EOF
Usage: ${1##*/} [OPTIONS] FILES|FOLDERS
@ -106,7 +105,7 @@ while getopts ":a:b:cCe:fho:pPsS:tv:" opt; do
OVERWRITE="-y"
OPT_OVERWRITE=true;;
h)
_printhelp "$0"
_usage "$0"
exit 1 ;;
o)
TC_VIDEO_OPT="$OPTARG" ;;
@ -124,15 +123,15 @@ while getopts ":a:b:cCe:fho:pPsS:tv:" opt; do
OPT_REMOVE_TITLE=true ;;
v)
VIDEO_PARAM="-c:v $OPTARG" ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1 ;;
esac
done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit
fi
@ -141,15 +140,13 @@ if ! command -v ffmpeg >/dev/null; then
exit
fi
_highfreq()
{
_highfreq() {
awk 'BEGIN{max=0} /crop=/ {t[$NF]++; if (t[$NF]>max) {max=t[$NF]; val=$NF}} END{print val}'
}
## Usage: _cropvalue FILE STEP
## Return the crop values as ffmpeg output them.
_cropvalue()
{
_cropvalue() {
local step=$2
for i in $(seq $step $step $((5*$step))); do
ffmpeg -nostdin -ss $i -i "$1" -t 10 -vf "cropdetect=24:2:0" -f null - 2>&1
@ -161,8 +158,7 @@ _cropvalue()
## If input codec is $AUDIO_CODEC, we copy. If some stream bitrates are missing
## or 0, we encode it to a default value. If default value is 0, then we copy
## stream.
_audiobitrate()
{
_audiobitrate() {
local bitrate
for i in $(seq 0 $(($format_nb_streams-1)) ); do
@ -187,8 +183,7 @@ _audiobitrate()
done
}
_transcode()
{
_transcode() {
echo "==> [$1]"
OUTPUT="${1%.*}.$EXT"
[ -e "$OUTPUT" ] && OUTPUT="${1%.*}-$(date '+%F-%H%M%S').$EXT"

View File

@ -25,8 +25,8 @@ for i ; do
DIRNAME="${FILE%/*}"
BASENAME="${FILE##*/}"
BASENAME="${BASENAME%.*}"
rm -v $(for j in \
aux bbl blg cp cps fn glg glo gls idx ilg ind ky lof log maf mt mtc nav out pg snm synctex.gz synctex tns toc tp vr vrs xdy
rm -v $(
for j in aux bbl blg cp cps fn glg glo gls idx ilg ind ky lof log maf mt mtc nav out pg snm synctex.gz synctex tns toc tp vr vrs xdy
do
echo "$DIRNAME/$BASENAME.$j"
done) 2>/dev/null

View File

@ -2,8 +2,7 @@
## TODO: support for long texts.
_printhelp ()
{
_usage () {
cat<<EOF
Usage: ${1##*/} [-i source-language] target-language [text]
@ -47,15 +46,15 @@ OPT_LONG=false
while getopts ":hi:l" opt; do
case $opt in
h)
_printhelp "$0"
_usage "$0"
exit 1
;;
i)
SL="$OPTARG" ;;
l)
OPT_LONG=true ;;
?)
_printhelp "$0"
\?)
_usage "$0"
exit 1
;;
esac
@ -64,7 +63,7 @@ done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$0"
_usage "$0"
exit 1
fi
@ -72,8 +71,7 @@ TL=$1
shift
_filter()
{
_filter () {
if ! $OPT_LONG; then
sed -e 's/\[\[\["\([^"]*\).*/\1/' -e 's/"//g'
echo
@ -118,8 +116,7 @@ EOF
fi
}
_translate()
{
_translate () {
TEXT="$(tr '\n' ' ' | sed 's/[\t ]\+/%20/g')"
## If input is not a single word, disable alternative translations. We use a
## point in the grep string to ignore any space at the end.

View File

@ -15,8 +15,7 @@ EOF
fi
check()
{
check () {
for i ; do
if ! command -v $i >/dev/null 2>&1; then
echo >&2 "'$i' not found in PATH. Exiting."
@ -24,6 +23,7 @@ check()
fi
done
}
check transmission-daemon transmission-remote-cli
[ $(ps -U $USER | grep -c transmission-da) -eq 0 ] && transmission-daemon
@ -35,4 +35,3 @@ else
sleep 1
transmission-remote "$@"
fi

View File

@ -23,4 +23,3 @@ fi
WINEDEBUG=fps wine "$@" 2>&1 | tee /dev/stderr | \
sed $OPT_UNBUF -n '/^trace:fps:/{s/.* \([^ ]*\)fps/\1/;p}' | \
osd_cat -l1 -f "-*-*-*-*-*-*-32-*-*-*-*-*-*-*" -O1 -c "yellow"