[chef-dev] Re: CHEF-2398 : adding a cwd attr to the link resource


Chronological Thread 
  • From: Maciej Pasternacki < >
  • To: Laurent Desarmes < >
  • Cc: Joseph Holsten < >,
  • Subject: [chef-dev] Re: CHEF-2398 : adding a cwd attr to the link resource
  • Date: Sun, 15 Apr 2012 13:15:36 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=pasternacki.net; h=subject :mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; q=dns; s= pasternacki.net; b=P2cuQIDM6xbp+mXawG2je5sC6F9I9mUgxw8A2hBsItHNY sJG6Ogn3IqYGz+2EMw7PVM3UJtpM0qcBrr5bxvAJe6BGaWExmY9JQmaw6vKpCcJo UEGAwbfCUV3OQeNpQKVV7A4eI19mPug5QTPW3xAGrkQL6Cr2Q2RgYl4kfh2oP8=


On Apr 15, 2012, at 12:50 , Laurent Desarmes wrote:

>> Could you explain why this is useful? I haven't used them in ages, so I 
>> can't
>> remember what they're good for (besides surprising me).
>
>> In particular, I have no idea what the example in the ticket is supposed to
>> do.
> 
> Hi
> 
> the example in the ticket is supposed to maintain a symbolic link in
> /boot called "linux" with a relative reference to "linux-3.0.0"
> 
> 
> to make it simple, can you see the difference between:
> 1) ln -s /boot/linux-3.0.0 /boot/linux
> vs
> 2) cd /boot; ln -s linux-3.0.0 linux

You don't need to chdir(), 1) is equivalent to in -s linux-3.0.0 /boot/linux

Relative symlinks are relative to the directory where the symlink is placed, 
not getcwd.

You can use Pathname#relative_path_from to make the calculations for you:
1.9.2p290 :003 > 
Pathname.new('/boot/linux-3.0.0').relative_path_from(Pathname.new('/boot/linux').dirname)
 => #<Pathname:linux-3.0.0> 




Archive powered by MHonArc 2.6.16.

§