public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option)
@ 2014-09-02 14:43 Dat Head
  2014-09-02 14:57 ` Marco Atzeri
  2014-09-04  8:51 ` Csaba Raduly
  0 siblings, 2 replies; 6+ messages in thread
From: Dat Head @ 2014-09-02 14:43 UTC (permalink / raw)
  To: The Cygwin Mailing List

Cygwin 1.7.30-1

$ ls -l *-fixed.flac
-rw-r--r-- 1 foo None 0 Sep  1 13:47 a-fixed.flac
-rw-r--r-- 1 foo None 0 Sep  1 13:47 b-fixed.flac

$ rename '-fixed' '' *-fixed.flac
rename: unknown option -- f

Usage:
 rename [options] expression replacement file...

Options:
 -v, --verbose    explain what is being done
 -V, --version    output version information and exit
 -h, --help       display this help and exit

escaping dash with backslash doesn't work either.
this used to work in a MUCH older version of cygwin.

I tried to get a newer version in util-linux to compile but ran into a
lot of troubles.  i also saw some notes that some cyg-specific items were
removed from newer util-linux which is why maybe it hasn't been upgraded?

also of note is rename works fine in redhat5/6 because they use util-linux-ng

$ uname -a
CYGWIN_NT-6.1 frog2 1.7.30(0.272/5/3) 2014-05-23 10:36 x86_64 Cygwin

$ rename -V
rename from util-linux 2.21.2

I had to write a cheap sed script to get me by for now but it isn't very
robust, but does what I need it to


-- 
"Ethics cannot spring from laws as you think,
Moral is something you feel" - Anders Osborne

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option)
  2014-09-02 14:43 cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option) Dat Head
@ 2014-09-02 14:57 ` Marco Atzeri
  2014-09-04  8:51 ` Csaba Raduly
  1 sibling, 0 replies; 6+ messages in thread
From: Marco Atzeri @ 2014-09-02 14:57 UTC (permalink / raw)
  To: cygwin

On 02/09/2014 16:43, Dat Head wrote:
> Cygwin 1.7.30-1
>
> $ ls -l *-fixed.flac
> -rw-r--r-- 1 foo None 0 Sep  1 13:47 a-fixed.flac
> -rw-r--r-- 1 foo None 0 Sep  1 13:47 b-fixed.flac
>
> $ rename '-fixed' '' *-fixed.flac
> rename: unknown option -- f

you need to tell rename that the options are ended with --

$ rename -- '-fixed' '' *-fixed.flac

$ ls *flac
a.flac  b.flac


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option)
  2014-09-02 14:43 cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option) Dat Head
  2014-09-02 14:57 ` Marco Atzeri
@ 2014-09-04  8:51 ` Csaba Raduly
  1 sibling, 0 replies; 6+ messages in thread
From: Csaba Raduly @ 2014-09-04  8:51 UTC (permalink / raw)
  To: cygwin list

Hi

On Tue, Sep 2, 2014 at 4:43 PM, Dat Head  wrote:
> Cygwin 1.7.30-1
>
> $ ls -l *-fixed.flac
> -rw-r--r-- 1 foo None 0 Sep  1 13:47 a-fixed.flac
> -rw-r--r-- 1 foo None 0 Sep  1 13:47 b-fixed.flac
>
> $ rename '-fixed' '' *-fixed.flac
> rename: unknown option -- f
>
> Usage:
>  rename [options] expression replacement file...
>
> Options:
>  -v, --verbose    explain what is being done
>  -V, --version    output version information and exit
>  -h, --help       display this help and exit

This is not a Cygwin problem. Unix tools usually interpret an argument
starting with a dash as options:

csabaraduly@ubu:/tmp/ren $ uname -a
Linux ubu 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC
2014 x86_64 x86_64 x86_64 GNU/Linux

csabaraduly@ubu:/tmp/ren $ cat /etc/issue
Ubuntu 14.04.1 LTS \n \l

csabaraduly@ubu:/tmp/ren $ ls -l *-fixed.flac
-rw-rw-r-- 1 csabaraduly csabaraduly 0 Sep  4 10:42 a-fixed.flac
-rw-rw-r-- 1 csabaraduly csabaraduly 0 Sep  4 10:42 b-fixed.flac

csabaraduly@ubu:/tmp/ren $ rename '-fixed' '' *-fixed.flac
Unknown option: i
Unknown option: x
Unknown option: e
Unknown option: d
Usage: rename [-v] [-n] [-f] perlexpr [filenames]


Marco already showed how to stop an argument with a leading dash from
being treated as options.

Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option)
  2014-09-04 10:17 ` Marco Atzeri
@ 2014-09-04 11:53   ` Eric Blake
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2014-09-04 11:53 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2317 bytes --]

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.

> 
> 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.


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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option)
  2014-09-03 21:17 Dat Head
@ 2014-09-04 10:17 ` Marco Atzeri
  2014-09-04 11:53   ` Eric Blake
  0 siblings, 1 reply; 6+ messages in thread
From: Marco Atzeri @ 2014-09-04 10:17 UTC (permalink / raw)
  To: cygwin

On 03/09/2014 23:17, Dat Head wrote:
> On Tue, Sep 2, 2014 at 10:57 AM, Marco Atzeri <marco.atzeri@gmail.com> wrote:
>> On 02/09/2014 16:43, Dat Head wrote:
>>>
>>> Cygwin 1.7.30-1
>>>
>>> $ ls -l *-fixed.flac
>>> -rw-r--r-- 1 foo None 0 Sep  1 13:47 a-fixed.flac
>>> -rw-r--r-- 1 foo None 0 Sep  1 13:47 b-fixed.flac
>>>
>>> $ rename '-fixed' '' *-fixed.flac
>>> rename: unknown option -- f
>>
>>
>> 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)

curious because it is the almost standard (gnu) solution in
  most of the utilities.
I guess it is included in most used option parser

touch, mv , cp, .. are all working in the same way.

Otherwise try to rename/move a file called "-v" ...
(without using "./-v" )

> i'm not complaining, i love cygwin!
>
> that is a quite old version of util-linux I wonder does anyone know
> the factors involved in staying with that one? (everything else is
> mostly so wonderfully almost bleeding edge [which I like!])

It is working and the maintainer sees no reason to change it ;-)

I don't think basic stuff needs to be changed a lot.

Regards
Marco


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option)
@ 2014-09-03 21:17 Dat Head
  2014-09-04 10:17 ` Marco Atzeri
  0 siblings, 1 reply; 6+ messages in thread
From: Dat Head @ 2014-09-03 21:17 UTC (permalink / raw)
  To: The Cygwin Mailing List

On Tue, Sep 2, 2014 at 10:57 AM, Marco Atzeri <marco.atzeri@gmail.com> wrote:
> On 02/09/2014 16:43, Dat Head wrote:
>>
>> Cygwin 1.7.30-1
>>
>> $ ls -l *-fixed.flac
>> -rw-r--r-- 1 foo None 0 Sep  1 13:47 a-fixed.flac
>> -rw-r--r-- 1 foo None 0 Sep  1 13:47 b-fixed.flac
>>
>> $ rename '-fixed' '' *-fixed.flac
>> rename: unknown option -- f
>
>
> 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)

i'm not complaining, i love cygwin!

that is a quite old version of util-linux I wonder does anyone know
the factors involved in staying with that one? (everything else is
mostly so wonderfully almost bleeding edge [which I like!])

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-04 11:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 14:43 cygwin rename util doesn't parse leading dash in expression argument correctly (thinks it is an option) Dat Head
2014-09-02 14:57 ` Marco Atzeri
2014-09-04  8:51 ` Csaba Raduly
2014-09-03 21:17 Dat Head
2014-09-04 10:17 ` Marco Atzeri
2014-09-04 11:53   ` Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).