From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17236 invoked by alias); 17 Aug 2015 12:19:45 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20425 Received: (qmail 7421 invoked from network); 17 Aug 2015 12:19:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=P2U7VWFnm+n/1m0JpIFTYkyFxq0EdZlVW4LJXXlnndw=; b=C7WZ07KPdYM8KIqyNEbbahCBFWYXo4sXlWj0IFHrM7AEo8jdS26HJGNcPx07XB063Q L7vqvOPHKClzpupycLdY7TPSzR/v6R/pkNmZoaEBzuh7yJKOEvb6NekP32ioVA7s3wk2 5VPABtQMdhDMQVke9kppY2eSnu29WqX2NsIi7pAcw4x+yGpAlgPeVhvBv0FwxtRn6s/v kwG90bnb5ICsTANaOf/cQY5gW6wkkZBkyTN2sgyYCd/ZtjDyfbeo0YcUaHX6GTwRAPZU f0lU/y3Sakzb6rN3gs+ev8pj6PAyGguL8hkU0bUdfXitnFJ9IEEyOBRTSAIWFLCDXXk8 L2bw== X-Received: by 10.180.218.227 with SMTP id pj3mr32603135wic.59.1439813981438; Mon, 17 Aug 2015 05:19:41 -0700 (PDT) Date: Mon, 17 Aug 2015 13:19:39 +0100 From: Stephane Chazelas To: zsh-users@zsh.org Subject: Re: translate all sequences of whitespace/underscores to single dashes Message-ID: <20150817121939.GA6930@chaz.gmail.com> Mail-Followup-To: zsh-users@zsh.org References: <87r3n2dav7.fsf@nl106-137-147.student.uu.se> <20150817094752.53c314fe@pwslap01u.europe.root.pri> <9D99B267-5DDD-4C5B-A33A-C5A0251A4B9F__19706.0165032328$1439813299$gmane$org@kba.biglobe.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9D99B267-5DDD-4C5B-A33A-C5A0251A4B9F__19706.0165032328$1439813299$gmane$org@kba.biglobe.ne.jp> User-Agent: Mutt/1.5.21 (2010-09-15) 2015-08-17 20:27:22 +0900, Jun T.: > In theory, if we want the same effect as the original code > (which uses 'tr -s "-"'), we need > > ${x//[-_[:space:]]##/-} > > so that x='a_-_z' becomes 'a-z' (not 'a---z'). > > BTW, the line > mv $f $new_name 2> /dev/null > in the function clean-filename() is dangerous, because two files > $f can have the same $new_name, in which case one of them is lost > (or $new_name may already exist before the function is called). [...] Note that zmv accounts for that (and also adds the missing "--") (and turns on extendedglob). zmv '*' '${f//[-_[:space:]]##/-}' -- Stephane