Tcl Source Code

View Ticket
Login
Ticket UUID: 1816166
Title: [file link -symbolic] fails on some relative targets
Type: Bug Created on: 2007-10-18 22:39:33
Submitter: coldstore Assigned to: vincentdarley
Subsystem: 37. File System Severity:
Priority: 8 Last modified: 2008-01-14 06:23:58
Status: Open Closed by: dgp
Resolution: Duplicate Closed on: 2007-10-19 04:29:24
Version: obsolete: 8.5b2
Description:
The following transcript illustrates a problem - none of the following commands should fail.

% file delete -force td
% file mkdir td
% file mkdir td/td1
% file link -symbolic td/l1 td/td1
could not create new link "td/l1": target "td/td1" doesn't exist
% file link -symbolic td/l1 ./td/td1
could not create new link "td/l1": target "./td/td1" doesn't exist
% file link -symbolic ./td/l1 ./td/td1
could not create new link "./td/l1": target "./td/td1" doesn't exist
% cd td
% file link -symbolic l1 ./td/td1
could not create new link "l1": target "./td/td1" doesn't exist
% file link -symbolic l1 ./td1
./td1
% file link -symbolic l2 ./td1
./td1
% cd ..
% file link -symbolic l3 ./td/td1
./td/td1
% file link -symbolic l4 td/td1
td/td1
%
User Comments:
andreas_kupries added on 2007-10-19 05:42:13:
Logged In: YES 
user_id=75003
Originator: NO

Additional data point: With an 8.4.15 tclsh the script works.

dgp added on 2007-10-19 11:29:24:
Logged In: YES 
user_id=80530
Originator: NO


Please check how much this
is a Dup of 833713
and 951964

coldstore added on 2007-10-19 13:56:13:
Logged In: YES 
user_id=19214
Originator: YES

similar to 833713 but instead of normalizing the link target, it errors out.

coldstore added on 2007-10-20 07:15:59:
Logged In: YES 
user_id=19214
Originator: YES

The following comment in unix/tclUnixFile.c may explain the cause of the problem:

 * If we're making a symbolic link and the path is relative, then we
 * must check whether it exists _relative_ to the directory in which
 * the src is found (not relative to the current cwd which is just not
 * relevant in this case).

It seems that the link command interprets target relative to the target and not the cwd.

This is arguably idiosyncratic, but is at least coherent, and could probably be covered by making such behaviour explicit in the documentation.

hobbs added on 2008-01-14 06:23:58:
Logged In: YES 
user_id=72656
Originator: NO

Did the tester build with mingw-gcc or MSVC?  If gcc, this may be a dup of 1852661.