This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: symbolic link untar issue

Hash: SHA1

According to Tom Rodman on 8/20/2007 5:58 PM:
> These steps 'hide bash', so invoking bash again fails:
>   /tmp $ uname -a
>   CYGWIN_NT-5.0 argon 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
>   /tmp $ tar tvf bar.tar
>   drwxrwxr-x staffuser1/XYZ_ES_STAFF 0 2007-08-20 17:29 ZZ/
>   lrwxrwxrwx staffuser1/XYZ_ES_STAFF 0 2007-08-20 17:29 ZZ/bash2 -> /bin/bash
>   /tmp $ tar xpf bar.tar; tar xpf bar.tar #2nd untar does the damage

It looks like tar is trying to follow the symlink, and touches what the
symlink points to (I'm not sure why tar is insisting on following the
link; that may be an upstream bug).  Anyway, since the symlink was created
without pointing to the .exe extension, tar is thus getting confused
between touching bash.exe and creating bash with no extension.

This seems like a corner case, so I'm not sure how much time I will spend
trying to work around it, but thanks for reporting it.  On the other hand,
since tar files created on platforms without .exe suffixes are likely to
look like this, maybe I should at least investigate making tar smarter
about extraction of links.

> Is that an old style cygwin snybolic link?  If so how do I identify all of them,
> so I might update them on my system?

No, it is not an old-style link, because it has the .lnk suffix when
viewed via Windows.  However, it is not a link that would normally be
created by the current coreutils, since I have added some .exe magic into
ln when symlinking against existing .exes:

$ ln -s /bin/bash bash2
$ readlink bash2

Therefore, if you are worried about the existence of symlinks whose
contents leave out the .exe suffix, you could do something like the
following to find candidate links that might need correction:

$ find [directory] -maxdepth 1 -type l \( -lname '*[^.][^e][^x][^e]' -o
- -lname '???' -o -lname '??' -o -lname '?' \) -print

Beyond that, there are probably ways to automate replacing the broken
contents of such links with automatic .exe suffixes where appropriate,
once you realize that this idiom will make the conversion:

$ ln -fs "$(readlink "./bash2")" "./bash2"

> Cleanup.., how to delete the zero byte '/bin/bash':
>   /tmp/ZZ $ (cd /bin ; chmod 777 bash;cmd /c del bash; ls -l bash)

Yuck.  Why rely on cmd?  It is simpler to 'rm bash', which will delete the
non-suffix version without touching the .exe version.  Also, it is not
necessary to chmod 777 the empty file; you can delete files with 0
permissions (although you may have to answer an interactive question to do

- --
Don't work too hard, make some time for fun as well!

Eric Blake   
volunteer cygwin tar maintainer
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at
Comment: Using GnuPG with Mozilla -


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]