From 71ceb1c16102f82e15375afb44e0ac59e39eaa23 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 15 Jan 2007 14:50:25 +0000 Subject: * Handle multiple indirect symlinks when loading a Nix expression. --- src/libexpr/parser.y | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 8ac3345c1f2e..3540058bc1e0 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -369,9 +369,12 @@ Expr parseExprFromFile(EvalState & state, Path path) /* If `path' is a symlink, follow it. This is so that relative path references work. */ struct stat st; - if (lstat(path.c_str(), &st)) - throw SysError(format("getting status of `%1%'") % path); - if (S_ISLNK(st.st_mode)) path = absPath(readLink(path), dirOf(path)); + while (true) { + if (lstat(path.c_str(), &st)) + throw SysError(format("getting status of `%1%'") % path); + if (!S_ISLNK(st.st_mode)) break; + path = absPath(readLink(path), dirOf(path)); + } /* If `path' refers to a directory, append `/default.nix'. */ if (stat(path.c_str(), &st)) -- cgit 1.4.1