Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
unexpected behavior between source and fish #2643
Stumbled across some unexpected behavior when using
The contents of
set myvar (dirname (status -f)) echo $myvar
➜ mydir source test.fish .
However, when using
➜ mydir fish test.fish /private/tmp/mydir
Is this expected? If so is there a workaround to keep the behavior consistent between the two of them? In this case we're expecting the absolute path to the file.
Both are technically correct and the documentation is ambiguous. It just says "prints the filename of the currently running script." without stating whether it will always result in an absolute path. Having said that I find the inconsistency surprising and would vote for updating the code and docs to state the path will always be absolute.
It's weird that fish would fully resolve the path when passed a file. This was introduced in 06fd1aa a long time ago (the call to
I'm unsure if it's better to show the relative path, absolute path, or fully resolved path (i.e. absolute with symlinks resolved). I think that resolving symlinks is bad, because some scripts are symlinked to each other and switch off their name to decide what to do. But as for absolute vs relative, I'm not sure - are there any legitimate uses for knowing the relative path?
Yeah, upon further reflection I agree that defining it to always produce a relative path if one was used in the first place makes more sense than always converting to an absolute path since there is a trivial command for doing the latter. Obviously if the user explicitly specifies an absolute path then that is what they'll get from