Ask a Question related to Ruby, Design and Development.

  1. #1

    Default Fileutils.cp bug?

    I'm experiencing the following behavior in the latest CVS copy of ruby on
    both Windows and Linux. I think it's a bug.

    [chad@ns1 chad]$ cat test
    Goodbye Cruel World!
    [chad@ns1 chad]$ ruby -rfileutils -e 'FileUtils.cp("test", "test")'

    [chad@ns1 chad]$ cat test
    [chad@ns1 chad]$ ls -l test
    -rw-rw-r-- 1 chad chad 0 Nov 17 08:35 test
    [chad@ns1 chad]$


    I would suggest the following small change.

    Do others agree that this is a bug?

    Thanks,
    Chad




    Index: fileutils.rb
    ================================================== =================
    RCS file: /src/ruby/lib/fileutils.rb,v
    retrieving revision 1.22
    diff -u -c -r1.22 fileutils.rb
    cvs server: conflicting specifications of output style
    *** fileutils.rb 30 Oct 2003 09:36:39 -0000 1.22
    --- fileutils.rb 17 Nov 2003 13:11:43 -0000
    ***************
    *** 312,317 ****
    --- 312,318 ----
    return if options[:noop]

    fu_each_src_dest(src, dest) do |s,d|
    + raise ArgumentError, "`#{src}' and `#{dest}' are the same file"
    unless (
    src != dest)
    fu_preserve_attr(options[:preserve], s, d) {
    copy_file s, d
    }



    Chad Fowler Guest

  2. Similar Questions and Discussions

    1. FileUtils - :preserve does not preserve mtime of directories on Windoze
      Hi Rubyists, I have been trying to copy whole directory trees while preserving mtime of subdirectories and file, using FileUtils.cp_r with the...
  3. #2

    Default Re: Fileutils.cp bug?

    Hi,

    On Mon, 17 Nov 2003, Chad Fowler wrote:
    > I'm experiencing the following behavior in the latest CVS copy of ruby on
    > both Windows and Linux. I think it's a bug.
    >
    > [chad@ns1 chad]$ cat test
    > Goodbye Cruel World!
    > [chad@ns1 chad]$ ruby -rfileutils -e 'FileUtils.cp("test", "test")'
    >
    > [chad@ns1 chad]$ cat test
    > [chad@ns1 chad]$ ls -l test
    > -rw-rw-r-- 1 chad chad 0 Nov 17 08:35 test
    > [chad@ns1 chad]$
    >
    >
    > I would suggest the following small change.
    >
    > Do others agree that this is a bug?
    Well, I do think it's a bug ... but the patch is not enough, imho:

    (5/wejn/ns) x$ echo "goodbye" > src
    (5/wejn/ns) x$ ruby18 -rfileutils -e 'FileUtils.cp("src", "src")'
    /usr/local/ruby-1.8.0/lib/ruby/1.8/fileutils.rb:315:in `cp': `src' and `src' are the same file (ArgumentError)
    from /usr/local/ruby-1.8.0/lib/ruby/1.8/fileutils.rb:314:in `fu_each_src_dest'
    from /usr/local/ruby-1.8.0/lib/ruby/1.8/fileutils.rb:314:in `cp'
    from -e:1

    ... ok ... but:

    (5/wejn/ns) x$ ruby18 -rfileutils -e 'FileUtils.cp("src", "./src")'
    (5/wejn/ns) x$ ls -l src
    -rw-r--r-- 1 wejn wejn 0 Nov 17 15:04 src

    ... problem :-(

    What about comparation of [dev,inode] ?

    Sincerely,
    Michal
    --
    # Michal Safranek, email:
    a=(("a".."z").to_a+["@","."]);p(("%b"%[0x645bbb83a6a496]
    ).scan(/...../).map{|x|a[Integer("0b"+x)]}.join.reverse)


    Wejn Guest

  4. #3

    Default Re: Fileutils.cp bug?

    On Mon, 17 Nov 2003, Wejn wrote:

    # Hi,
    #
    # On Mon, 17 Nov 2003, Chad Fowler wrote:
    #
    # > I'm experiencing the following behavior in the latest CVS copy of ruby on
    # > both Windows and Linux. I think it's a bug.
    # >
    # > [chad@ns1 chad]$ cat test
    # > Goodbye Cruel World!
    # > [chad@ns1 chad]$ ruby -rfileutils -e 'FileUtils.cp("test", "test")'
    # >
    # > [chad@ns1 chad]$ cat test
    # > [chad@ns1 chad]$ ls -l test
    # > -rw-rw-r-- 1 chad chad 0 Nov 17 08:35 test
    # > [chad@ns1 chad]$
    # >
    # >
    # > I would suggest the following small change.
    # >
    # > Do others agree that this is a bug?
    #
    # Well, I do think it's a bug ... but the patch is not enough, imho:
    #
    # (5/wejn/ns) x$ echo "goodbye" > src
    # (5/wejn/ns) x$ ruby18 -rfileutils -e 'FileUtils.cp("src", "src")'
    # /usr/local/ruby-1.8.0/lib/ruby/1.8/fileutils.rb:315:in `cp': `src' and `src' are the same file (ArgumentError)
    # from /usr/local/ruby-1.8.0/lib/ruby/1.8/fileutils.rb:314:in `fu_each_src_dest'
    # from /usr/local/ruby-1.8.0/lib/ruby/1.8/fileutils.rb:314:in `cp'
    # from -e:1
    #
    # ... ok ... but:
    #
    # (5/wejn/ns) x$ ruby18 -rfileutils -e 'FileUtils.cp("src", "./src")'
    # (5/wejn/ns) x$ ls -l src
    # -rw-r--r-- 1 wejn wejn 0 Nov 17 15:04 src
    #
    # ... problem :-(
    #
    # What about comparation of [dev,inode] ?

    Good point, Michal. I thik I need some post-RubyConf rest :)

    How about (File.expand_path("src") == File.expand_path("dest"))?



    Chad Fowler Guest

  5. #4

    Default Re: Fileutils.cp bug?

    Hi,
    > # What about comparation of [dev,inode] ?
    >
    > Good point, Michal. I thik I need some post-RubyConf rest :)
    >
    > How about (File.expand_path("src") == File.expand_path("dest"))?
    wow ... even better :-) I think it will avoid possible problems
    on Win32 (I'm not sure how stat() behaves there regarding to
    dev and inode#).

    M.
    --
    # Michal Safranek, email:
    a=(("a".."z").to_a+["@","."]);p(("%b"%[0x645bbb83a6a496]
    ).scan(/...../).map{|x|a[Integer("0b"+x)]}.join.reverse)


    Wejn Guest

  6. #5

    Default Re: Compiling tcltklib

    Hi,

    At Tue, 18 Nov 2003 00:30:48 +0900,
    Zach Dennis wrote:
    > Ok I've got the compiling part of Ruby set. Ruby 1.8.1 is up and going.
    > However I can't seem to get the Tcltklib to compile. What does the line look
    > like when you are using the "--with" statements?
    Give them to make as configure_args.
    > make configure_args="--with-tcl-dir=I:/source/tcl"
    > I've tried things similar to:
    >
    > bcc32\configure --with...eetc...etc..
    >
    > when i ran the configure.bat for the ruby compile and i tried running it
    > from the tcltklib directory. Any ideas what the command looks like from a
    > windows command prompt? It gives me an error upon unknown "--with..."
    A batch file is too poor to anlyze them.

    --
    Nobu Nakada

    nobu.nokada@softhome.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139