#! /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