[p4ruby] fix for symlink-in-PWD problem
jeffperforce at gmail.com
Fri Mar 7 11:36:49 PST 2008
On Fri, Mar 7, 2008 at 8:46 AM, Tony Smith <tony at smee.org> wrote:
> The easier workaround is:
> ENV.delete( "PWD" )
> If PWD isn't present in the environment, then the Perforce API will fall back
> on using the result of getcwd(), which expands your symlink as required.
> Note that the PWD environment variable is intended to supress expansion of
> symlinks. Back in the early 90's it used to drive me nuts when I cd'd across
> a symlink and couldn't get back using 'cd ..'. PWD was the solution that the
> shells adopted for this and Perforce is simply following the convention.
> Most of the time that's what's wanted. When it isn't, deleting PWD from the
> environment usually solves the problem.
Deleting PWD makes the implementation slightly easier, but the
principle is the same. The workaround becomes:
class << self
alias_method :previous_new, :new
def new(*args, &block)
previous_pwd = ENV["PWD"]
ENV["PWD"] = previous_pwd
Do we have a philosophical disagreement? I want to fix this problem
for Joe Programmer once and for all. Would you rather have Joe
Programmer to run into the problem, become annoyed and spend time
googling, after which he may POSSIBLY find the magic solution of
ENV.delete("PWD")? Joe Programmer includes me. I want to help my
future self. Do you?
The above fix also has the advantage of not polluting ENV with a
deleted PWD, which may be used by some other component.
More information about the p4ruby