]> git.phdru.name Git - dotfiles.git/blobdiff - bin/recode-inplace
.fvwmrc: Refactor many SetVolumeAndBrowser functions into one with parameters
[dotfiles.git] / bin / recode-inplace
index e354b870f26d8d34299a781c9bf5e573af9b9746..149b4aed29860a3955837b5408b764d34f6fb2bc 100755 (executable)
@@ -1,13 +1,12 @@
 #! /bin/sh
+set -e
 
-fromenc="$1"
-shift
+tmpfile="`mktemp`"
+trap "exec rm -f $tmpfile" EXIT HUP INT QUIT PIPE TERM
 
-toenc="$1"
-shift
-
-tmpfile="`python -c 'import tempfile; print tempfile.mktemp()'`" &&
+. get_encodings
 
 for file in "$@"; do
-   iconv -f "$fromenc" -t "$toenc" "$file" >"$tmpfile" && cp "$tmpfile" "$file" && rm "$tmpfile"
+   iconv -f "$from_encoding" -t "$to_encoding" "$file" >"$tmpfile"
+   cp "$tmpfile" "$file"
 done