From dec80c219fe96901dbb20f48eb782d89e792f22a Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Tue, 19 Aug 2014 11:06:03 +0200 Subject: [PATCH] Scripts: Various fixes --- .scripts/netinit | 5 +++++ .scripts/pdfcompress | 10 +++++++++- .scripts/pkggen | 2 +- .scripts/renameswap | 2 +- .scripts/sanitize | 2 +- .scripts/tc-audio-scan | 2 +- .scripts/tc-text-2utf8 | 2 +- .scripts/tc-text-scan | 2 +- .scripts/texclean | 13 +++++++++---- 9 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.scripts/netinit b/.scripts/netinit index b7d31749..b2471d90 100755 --- a/.scripts/netinit +++ b/.scripts/netinit @@ -1,5 +1,10 @@ #!/usr/bin/env zsh +## This is a home-made network manager. Systems running systemd and dhcpcd are +## 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 diff --git a/.scripts/pdfcompress b/.scripts/pdfcompress index f5640448..15b2b186 100755 --- a/.scripts/pdfcompress +++ b/.scripts/pdfcompress @@ -71,7 +71,15 @@ for i ; do continue fi - OUTPUT="${i%.*}-compressed.pdf" + case "$i" in + */*) ;; + *) i="./$i" ;; + esac + DIRNAME="${i%/*}" + BASENAME="${i##*/}" + EXTNAME="${BASENAME##*.}" + BASENAME="${BASENAME%.*}" + OUTPUT="$DIRNAME/$BASENAME-compressed.pdf" if [ -e "$OUTPUT" ] && ! $OPT_OVERWRITE; then echo "$OUTPUT alredy present. Skipping." continue diff --git a/.scripts/pkggen b/.scripts/pkggen index 1e321eef..66d9518f 100755 --- a/.scripts/pkggen +++ b/.scripts/pkggen @@ -20,7 +20,7 @@ if [ "$(uname)" = "FreeBSD" ]; then fi ## TeXlive -if type tlmgr >/dev/null 2>&1; then +if command -v tlmgr >/dev/null 2>&1; then ## We use in the sed expressions. TEXLIVE_BASIC="$(mktemp)" tlmgr info collection-basic --list | sed -n '/^ /{s/ //g;p;}' | sort >"$TEXLIVE_BASIC" diff --git a/.scripts/renameswap b/.scripts/renameswap index 4b3e0379..f3f3e152 100755 --- a/.scripts/renameswap +++ b/.scripts/renameswap @@ -14,7 +14,7 @@ fi ## We need a temp file is case both files are in the same folder. We use the ## unsecure option since we do not want to create a empty file in ## advance. Indeed, creating a file with mktemp is problematic for folders since -## non-GNU mv can only move _into_ an exisintg folder. But we do not overwrite +## non-GNU mv can only move _into_ an existing folder. But we do not overwrite ## if file exists. TEMPFILE="$(mktemp -u "$1.XXXXXX")" diff --git a/.scripts/sanitize b/.scripts/sanitize index cc9a9d5b..8e5d6e2c 100755 --- a/.scripts/sanitize +++ b/.scripts/sanitize @@ -5,7 +5,7 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ]; then Usage: ${0##*/} FOLDERS Set file/directory owner and permissions according to current umask for current -used. +user. EOF exit fi diff --git a/.scripts/tc-audio-scan b/.scripts/tc-audio-scan index fa7efd8d..999fe5c6 100755 --- a/.scripts/tc-audio-scan +++ b/.scripts/tc-audio-scan @@ -1,6 +1,6 @@ #!/bin/sh -if ! command -v mediainfo >/dev/null; then +if ! command -v mediainfo >/dev/null 2>&1; then echo "mediainfo required." exit fi diff --git a/.scripts/tc-text-2utf8 b/.scripts/tc-text-2utf8 index ffaeb711..54ccb053 100755 --- a/.scripts/tc-text-2utf8 +++ b/.scripts/tc-text-2utf8 @@ -11,7 +11,7 @@ WARNING: It will fail for encodings other the one explicitly supported below. EOF fi -if ! command -v recode >/dev/null; then +if ! command -v recode >/dev/null 2>&1; then echo "recode needed." exit fi diff --git a/.scripts/tc-text-scan b/.scripts/tc-text-scan index 5687a2ab..a529d7dc 100755 --- a/.scripts/tc-text-scan +++ b/.scripts/tc-text-scan @@ -10,7 +10,7 @@ or "oe" instead of "œ". EOF fi -if ! command -v recode >/dev/null; then +if ! command -v recode >/dev/null 2>&1; then echo "recode needed." exit fi diff --git a/.scripts/texclean b/.scripts/texclean index ff85c7bd..bbfa2d17 100755 --- a/.scripts/texclean +++ b/.scripts/texclean @@ -17,13 +17,18 @@ fi for i ; do while read -r FILE; do - FILE_NOEXT="${FILE##*/}" - FILE_NOEXT="${FILE_NOEXT%.*}" - FILE_PATH="${FILE%/*}" + case FILE in + */*) ;; + *) + FILE="./$FILE" ;; + esac + 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 do - echo "$FILE_PATH/$FILE_NOEXT.$j" + echo "$DIRNAME/$BASENAME.$j" done) 2>/dev/null done <