delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/09/04/07:54:09

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; q=dns; s=default; b=TvgKU1
BPsJNHFbo9PcTfkHujm34zW88r0edJyl0GOb/RMfbgKpXGANfBDZAzpK48BNUrWb
IH/9PmQJhlt4PSNc7VduoOHXUwXYpIi94N8h44iz3f+V8suZ++CWuoAlbeoirb5D
UNbmtKMiYoIyfDzBMuoj9GSGLUWvdspEjWSjY=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; s=default; bh=M4h9TCWBrbyc
IMUNRHBIOTSKX9c=; b=TPKBoPMEIABSSJeTcnNnbStciXVrP1XHydoSnynUUUS9
AO1AN3qiygdMldH2LPBdj1+qjjU0mNsA2KhQKv6TrhR4B/2a8ICySxh5TTV7/H3K
dbqt4d/82KaJTTBXfDk8DwlVjC1PhXPa1zuvdGrtvrIbcgvDJQaSmudfsnzyUiE=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mx1.redhat.com
Message-ID: <540852BE.5070209@redhat.com>
Date: Thu, 04 Sep 2014 05:53:34 -0600
From: Eric Blake <eblake AT redhat DOT com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option)
References: <CAMQzRBp9ML_PpuqhWQeUx_79zdBfv=pqhpLrNOtd8LN+eR7+AQ AT mail DOT gmail DOT com> <54083C3E DOT 3010107 AT gmail DOT com>
In-Reply-To: <54083C3E.3010107@gmail.com>
OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg
X-IsSubscribed: yes

--HojLFFAI49fs0gckmsA8NBT5eamK4F9qg
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 09/04/2014 04:17 AM, Marco Atzeri wrote:

>>>
>>> you need to tell rename that the options are ended with --
>>>
>>> $ rename -- '-fixed' '' *-fixed.flac
>>>
>>> $ ls *flac
>>> a.flac  b.flac
>>
>> thanx for the tip, haven't had to use that since old days of  "startx
>> clientopts -- serveropts &"
>>
>> but yet again I'm roped with having to wrap another case statement
>> around pieces of scripts for cygwin specific items (because the same
>> syntax of "rename --" doesn't work on redhat linux or another distro a
>> friend tried for me)

Then that particular version of rename is broken.  But the bug is in
that Linux distro, and you still don't have a cygwin problem.

>=20
> curious because it is the almost standard (gnu) solution in
>  most of the utilities.

Not just GNU, but POSIX.  POSIX requires that most standardized apps
(all except for a few special-cased oldies like echo) interpret -- as
the end of options, EVEN when such apps don't have any standardized
options (for example, POSIX does not require 'basename' to support any
options, yet it requires 'basename -- a' and 'basename a' to behave
identically).  POSIX also recommends that all (non-standard) apps also
honor this convention, and makes it quite easy to do so - any app built
on top of the standardized getopt() (or the GNU extension getopt_long)
will automatically handle -- correctly.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html

Guideline 10:
    The first -- argument that is not an option-argument should be
accepted as a delimiter indicating the end of options. Any following
arguments should be treated as operands, even if they begin with the '-'
character.

The utilities in the Shell and Utilities volume of POSIX.1-2008 that
claim conformance to these guidelines shall conform completely to these
guidelines as if these guidelines contained the term "shall" instead of
"should".

It is recommended that all future utilities and applications use these
guidelines to enhance user portability. The fact that some historical
utilities could not be changed (to avoid breaking existing applications)
should not deter this future goal.


--=20
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


--HojLFFAI49fs0gckmsA8NBT5eamK4F9qg
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg

iQEcBAEBCAAGBQJUCFK+AAoJEKeha0olJ0NqNa0H/i480Ha4HAlDkYk0/z5cgCgu
5QxNJHM16ePi30AL9joGjcc2p4Yl/B16CR+f5Az82rXZ1s417MGX8ZrYang7QegE
diDc6VN0ec8mNZP4FK74zUMHC9sqC13q6cRc5kprO99UUmgp0cwgyXEUgeFM5ceE
awm5bWLHHJQQN2ZBwrRThigA3bJz3pTsbCRJUQb4YCSipQVW3+0GJsGUSaAlCYKO
WDcXi9E5SRhRqQQYuTBif7TsAqKs9FnTlgC6a9nZvIFU40MKV7szgnocq/byWX9H
OQ515Ntc2TVLIAXbZyu0vTbQ14rvcHiefb8s7oZYhcuwfqu/exUF5OgX3lxEoGU=
=4Cof
-----END PGP SIGNATURE-----

--HojLFFAI49fs0gckmsA8NBT5eamK4F9qg--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019