Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#170 tar -C option is broken

Binaries (396)
Tim Buck

The -C option to tar is supposed to change the program's working
directory. If you specify a path including a drive letter with the -C
option, tar will change drives, but not change paths. For example, if I
start out in D:\projects, and use a tar command with a -C option to
change to C:\, it will change to drive C:, but in whatever
directory was current on drive C: at the time (Windows maintains
different working directories for each drive letter). You can reproduce
this with:

C:] dir temp\test1
Volume in drive C is unlabeled Serial number is E473:2DEF
Directory of C:\temp\test1*

8/03/2004 16:41 <DIR> .
8/03/2004 16:41 <DIR> ..
7/22/2004 15:32 168 file1.txt
7/22/2004 15:32 168 file22.txt
336 bytes in 2 files and 2 dirs 8,192 bytes allocated

C:] cd temp
C:\temp] D:
D:\projects] tar cvf test1.tar -C c:/ temp/test1
tar: Cannot add file temp/test1: No such file or directory
tar: Error exit delayed from previous errors

But if you use the command line
tar cvf test1.tar -C c:/./ temp/test1
it works.


  • GnuWin

    Logged In: YES

    This bug report is accepted as valid and will be fixed in an
    upcoming release.

  • Logged In: NO

    Further, -C and -T don't seem to work. Whether -C is on the
    command line or in the -T file, the directory does not get
    picked up. -C and files on the command line work fine.

  • Logged In: NO

    not to beat a horse, -C doesn't seem to be exercised with -
    T -- dir 'xx' doesn't exist, a.txt contains 'b.txt' (non-

    C:>tar -cvf a.tar -C xx a.txt
    tar: Cannot change to directory xx: No such file or
    tar: Error is not recoverable: exiting now

    C:>tar -cvf a.tar -C xx -T a.txt
    tar: Cannot add file b.txt: No such file or directory
    tar: Error exit delayed from previous errors



Cancel   Add attachments