From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 12 Sep 2005 15:35:51 +0400 From: Alexey Tourbin To: ALT Devel discussion list Message-ID: <20050912113551.GI3290@solemn.turbinal.org> Mail-Followup-To: ALT Devel discussion list Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LQ77YLfPrO/qF/pM" Content-Disposition: inline Cc: Subject: [devel] cmdcache X-BeenThere: devel@altlinux.ru X-Mailman-Version: 2.1.5 Precedence: list Reply-To: ALT Devel discussion list List-Id: ALT Devel discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Sep 2005 11:36:53 -0000 Archived-At: List-Archive: List-Post: --LQ77YLfPrO/qF/pM Content-Type: multipart/mixed; boundary="bWEb1MG/o7IKOlQF" Content-Disposition: inline --bWEb1MG/o7IKOlQF Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Sep 11, 2005 at 09:06:44PM +0400, Alexey Tourbin wrote: > =EE=C1=D0=C9=D3=C1=CC =CE=C1 =DB=C5=CC=CC=C5, =D3 =CB=C5=DB=C9=D2=CF=D7= =C1=CE=C9=C5=CD =C4=CC=D1 =CB=C1=D4=C1=CC=CF=C7=CF=D7. =E4=CC=D1 =D2=CF=C2= =CF=D4=C1 =DC=D4=CF =D7=C1=D6=CE=CF -- > =CF=DE=C5=CE=D8 =C4=CF=CC=C7=CF (=D3 =D2=C1=D3=D0=C1=CB=CF=D7=CB=CF=CA = =D7=D3=C5=C8 rpm'=CF=D7) =D4=CF=CC=D8=CB=CF =CF=C4=C9=CE =D2=C1=DA =C2=D5= =C4=C5=D4 =D2=C1=C2=CF=D4=C1=D4=D8. =F0=CF =D0=CF=D7=CF=C4=D5 =CB=C5=DB=C9=D2=CF=D7=C1=CE=C9=D1 =CD=CE=C5 =D0= =D2=C9=DB=CC=C1 =D7 =C7=CF=CC=CF=D7=D5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F =DA=CE=C1= =C5=D4, =CB=C1=CB =D3=C4=C5=CC=C1=D4=D8 =CC=D5=DE=DB=C5, =D0=CF=C4=D3=CB=C1= =D6=C9=D4=C5 =D0=CC=C9=DA. --bWEb1MG/o7IKOlQF Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=cmdcache Content-Transfer-Encoding: quoted-printable #!/bin/sh -ef cmdcache() { if [ $# -lt 2 ]; then echo "cmdcache: not enough arguments" >&2 pod2usage --exit=3D2 cmdcache || [ $? =3D 2 ] return 2 fi local cmd=3D"$1"; shift local cdir=3D"$HOME/.cmdcache/${cmd##*/}" [ -d "$cdir" ] || mkdir -p -m700 "$cdir" || return 1 [ -n "${RANDOM##*0}" ] || find "$cdir" -type f -mtime +33 -atime +33 -dele= te local file; for file; do :; done if [ ! -e "$file" ]; then echo "cmdcache: $file: no such file or directory" >&2 return 1 fi local cache=3D"$*"; cache=3D"$cdir/${cache//[-.\/ ]/_}" if [ -f "$cache" ] && ! [ "$file" -nt "$cache" -o "$cache" -nt "$file" ]; = then cat "$cache" return fi local rc=3D0 local mtime0; mtime0=3D"$(stat --format $'%Y\n' "$file")" || return "$cmd" "$@" >"$cache" && touch -r "$file" "$cache" || rc=3D$? cat "$cache" =09 local mtime1; mtime1=3D"$(stat --format $'%Y\n' "$file")" || rc=3D$? if [ $rc =3D 0 -a "$mtime0" !=3D "$mtime1" ]; then echo "cmdcache: $file has changed" >&2 rc=3D1 fi [ $rc =3D 0 ] || rm -f "$cache" return $rc } if [ -z "$*" -a "${0##*/}" !=3D cmdcache ]; then : okay, maybe I am sourced elif [ "x$*" =3D x-h -o "x$*" =3D x--help ]; then pod2usage --exit=3D0 "$0" else=20 cmdcache "$@" fi : <<'__EOF__' =3Dhead1 NAME cmdcache - simple command cache based on timestamps =3Dhead1 SYNOPSIS B I [I...] I B B '' =3Dhead1 AUTHOR Written by Alexey Tourbin . =3Dhead1 COPYING Copyright (c) 2005 Alexey Tourbin, ALT Linux Team. This is free software; you can redistribute it and/or modify it under the t= erms of the GNU General Public License as published by the Free Software Foundat= ion; either version 2 of the License, or (at your option) any later version. =3Dcut __EOF__ --bWEb1MG/o7IKOlQF-- --LQ77YLfPrO/qF/pM Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFDJWgXfBKgtDjnu0YRAhFqAJ9oSrXjoiL9c46k9mNRtcoJDNihtwCcCJjO dqedkbc+DtCAyLaP4lcZH04= =d9jz -----END PGP SIGNATURE----- --LQ77YLfPrO/qF/pM--