From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 23 Sep 2022 17:17:13 +0300 From: Michael Shigorin To: devel@lists.altlinux.org Message-ID: <20220923141713.GX10489@imap.altlinux.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="sdtB3X0nJg68CQEu" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) Subject: [devel] iconv-i X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Sep 2022 14:17:14 -0000 Archived-At: List-Archive: List-Post: --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit Здравствуйте. Понадобилась тут обёртка вокруг iconv по аналогии с sed -i (перекодирование по месту); вдруг ещё кому пригодится. --  ---- WBR, Michael Shigorin / http://altlinux.org   ------ http://opennet.ru / http://anna-news.info --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=iconv-i #!/bin/sh # inplace iconv wrapper # # (c) Michael Shigorin , 2022 # GPLv2 with ukronazi exception: those supporting them better hide tmpfile="$(mktemp)" atexit() { rm -f "$tmpfile"; } trap atexit HUP INT QUIT args= file= for i in "$@"; do case "$i" in -l|--list|-\?|--help|--usage|-V|--version) exec iconv "$i";; -s|--silent) shift ;; -f|-t) shift args="$args $i $1" shift ;; -f*|-t*|--f*|--t*|-c) args="$args $i" shift ;; -o|-*) echo "$0: unsupported option \`$i'" >&2 exit 1 ;; *) file="$1" break ;; esac done [ -f "$file" ] || { echo "$0: $file does not exist" >&2 exit 2 } iconv $args < "$file" > "$tmpfile" && touch -r "$file" "$tmpfile" && mv "$tmpfile" "$file" --sdtB3X0nJg68CQEu--