From b12b21825c949ef9b9327c6a0c9e2d5601aaf0b2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 1 Dec 2011 16:41:43 +0000 Subject: * Allow '' syntax to be used in nix-instantiate, nix-build and nix-env, e.g., $ nix-env -f '' -i patchelf or $ nix-build '' -A login.test --- src/libexpr/common-opts.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/libexpr/common-opts.cc') diff --git a/src/libexpr/common-opts.cc b/src/libexpr/common-opts.cc index d029d2ec35b9..e0865d9fcc25 100644 --- a/src/libexpr/common-opts.cc +++ b/src/libexpr/common-opts.cc @@ -44,4 +44,15 @@ bool parseSearchPathArg(const string & arg, Strings::iterator & i, } +Path lookupFileArg(EvalState & state, string s) +{ + if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') { + Path p = state.findFile(s.substr(1, s.size() - 2)); + if (p == "") throw Error(format("file `%1%' was not found in the Nix search path (add it using $NIX_PATH or -I)") % p); + return p; + } else + return absPath(s); +} + + } -- cgit 1.4.1