#409 tar --files-from doesn't handle list files in CR-LF format

Tar
open
GnuWin
Binaries (396)
5
2012-07-26
2008-01-11
No

If lines of a list file passed to tar via --files-from end in CR-LF (DOS format), tar complains it is an invalid argument. Everything is fine when lines end with CR only (Unix format).

(Is it related to bug #1106883)

C:> echo foo > foo
C:> echo bar > bar
C:> echo foo > list
C:> echo bar >> list
C:> tar --create --file foobar.tar --files-from=list
tar: Cannot add file foo : Invalid argument
tar: Cannot add file bar : Invalid argument
tar: Error exit delayed from previous errors

Discussion

  • Lorenzo Cappelletti

    Logged In: YES
    user_id=279407
    Originator: YES

    It is possible to workaround this problem using sed (or dos2unix):

    sed -e "s/\r\n/\n/" < list | tar --create --file=foobar.tar --files-from=-

     
  • GnuWin

    GnuWin - 2008-02-24

    Logged In: YES
    user_id=217802
    Originator: NO

    You could also try to use bsdtar (http://gnuwin32.sourceforge.net/packages/libarchive.htm), which for ordinary purposes is easier to use.