From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18381 invoked from network); 11 Sep 2009 11:09:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 11 Sep 2009 11:09:41 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 20370 invoked from network); 11 Sep 2009 11:09:36 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Sep 2009 11:09:36 -0000 Received: (qmail 29491 invoked by alias); 11 Sep 2009 11:09:28 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27269 Received: (qmail 29467 invoked from network); 11 Sep 2009 11:09:26 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 11 Sep 2009 11:09:26 -0000 Received: from mail-fx0-f214.google.com (mail-fx0-f214.google.com [209.85.220.214]) by bifrost.dotsrc.org (Postfix) with ESMTP id B415F8026E39 for ; Fri, 11 Sep 2009 13:09:20 +0200 (CEST) Received: by fxm10 with SMTP id 10so723996fxm.45 for ; Fri, 11 Sep 2009 04:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=+OFc9iuYA4Le5mO4+DGpLe120FuVKRTskESmjXuhF8I=; b=Vw4gPEfGepe96ljnd3JU11hnlNbRHqna3Ps84NEzfK6+h/jUmhayhBYq1CARhnZ5jY bq6UwWuQfV3Q66c4KySZqu4XbUiVBiKSoXaVRj38/8oaacF23tgH20ZZg582hgMmyCXG NDmhcJs4jwb9S7Xovk73yyAhVxyoLSvlC83XM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=nG4sk0tV/vsgqhUBdOTYQ3BMMlTUXap7O24H1T95V3of9PyKgkI0Hcn0BYQBL3TkwI sv9iQqYOoloG1gNfEvhddxmcPLB5Q6gsKcQuKu3iJE2b6oPF+rYPJjVODUIBqMAYDwvO X7fxqkv8OlSixnO1u4wrYUEvneR3iUMGOzOK0= MIME-Version: 1.0 Received: by 10.223.81.65 with SMTP id w1mr1367756fak.46.1252667360158; Fri, 11 Sep 2009 04:09:20 -0700 (PDT) In-Reply-To: <20090911115837.64cb9243@news01> References: <20090911115837.64cb9243@news01> Date: Fri, 11 Sep 2009 11:09:20 +0000 Message-ID: Subject: Re: [PATCH] Remove perl dependency in zftp From: Baptiste Daroussin To: zsh-workers@sunsite.dk Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: ClamAV 0.94.2/9795/Fri Sep 11 07:51:32 2009 on bifrost X-Virus-Status: Clean the documentation of zshsftpsys should be change either as it says that it needs perl that is now not the case anymore. I didn't send a patch for the documentation, because lots of people has a better english than I do for documentation 2009/9/11 Peter Stephenson : > On Fri, 11 Sep 2009 10:37:32 +0000 > Baptiste Daroussin wrote: >> Hi, >> >> Here is a patch to remove the perl dependency in the zfrtime of zftp >> >> Seems to work for me > > Thanks, I'll take your word for it: =A0this tidies it up a little. > > Index: Functions/Zftp/zfrtime > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/zsh/zsh/Functions/Zftp/zfrtime,v > retrieving revision 1.1.1.1 > diff -u -r1.1.1.1 zfrtime > --- Functions/Zftp/zfrtime =A0 =A0 =A025 Apr 1999 15:43:58 -0000 =A0 =A0 = =A01.1.1.1 > +++ Functions/Zftp/zfrtime =A0 =A0 =A011 Sep 2009 10:57:16 -0000 > @@ -6,12 +6,13 @@ > =A0# > =A0# Unfortunately, since the time returned from FTP is GMT and > =A0# your file needs to be set in local time, we need to do some > -# hacking around with time. =A0At the moment this requires perl 5 > -# with the standard library. > +# hacking around with time. > > =A0emulate -L zsh > +zmodload zsh/datetime > > -local time gmtime loctime > +local time gmtime loctime year mon mday hr min sec y tmpdate > +local -i days_since_epoch > > =A0if [[ -n $3 ]]; then > =A0 time=3D$3 > @@ -21,25 +22,22 @@ > =A0fi > =A0[[ -z $time ]] && return 1 > > -# Now's the real *!@**!?!. =A0We have the date in GMT and want to turn > -# it into local time for touch to handle. =A0It's just too nasty > -# to handle in zsh; do it in perl. > -if perl -mTime::Local -e '($file, $t) =3D @ARGV; > -$yr =3D substr($t, 0, 4) - 1900; > -$mon =3D substr($t, 4, 2) - 1; > -$mday =3D substr($t, 6, 2) + 0; > -$hr =3D substr($t, 8, 2) + 0; > -$min =3D substr($t, 10, 2) + 0; > -$sec =3D substr($t, 12, 2) + 0; > -$time =3D Time::Local::timegm($sec, $min, $hr, $mday, $mon, $yr); > -utime $time, $time, $file and return 0;' $1 $time 2>/dev/null; then > - =A0print "Setting time for $1 failed. =A0Need perl 5." 2>1 > -fi > - > -# If it wasn't for the GMT/local time thing, it would be this simple. > -# > -# time=3D"${time[1,12]}.${time[13,14]}" > -# > -# touch -t $time $1 > - > -# } > +year=3D$time[1,4] > +mon=3D$time[5,6] > +mday=3D$time[7,8] > +hr=3D$time[9,10] > +min=3D$time[11,12] > +sec=3D$time[13,14] > + > +#count the number of days since epoch without the current day > +for y =A0in {1970..$(( $year - 1))}; do > + =A0strftime -s tmpdate -r "%Y/%m/%d" ${y}/12/31 > + =A0days_since_epoch+=3D$(strftime "%j" $tmpdate) > +done > +strftime -s tmpdate -r "%Y/%m/%d" $year/$mon/$(( $mday - 1 )) > +days_since_epoch+=3D$(strftime "%j" $tmpdate) > +# convert the time in number of seconds (this should be equivalent to ti= megm) > +time=3D$(( $sec + 60 * ( $min + 60 * ($hr + 24 * $days_since_epoch)) =A0= )) > +#Convert it back to CCYYMMDDhhmmSS > +strftime -s time "%Y%m%d%H%M%S" ${EPOCHSECONDS} > +touch -t ${time[1,12]}.${time[13,14]} $1 > > > -- > Peter Stephenson =A0 =A0 =A0 =A0 =A0 =A0Software Engineer > Tel: +44 (0)1223 692070 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Cambridge Sil= icon Radio Limited > Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ= , UK > > > Member of the CSR plc group of companies. CSR plc registered in England a= nd Wales, registered number 4187346, registered office Churchill House, Cam= bridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom >