From b995c17f0eb8d9598f339c080c467101c1f55feb Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 11 Mar 2024 10:02:09 +0100 Subject: Merge pull request #10208 from 9999years/print-strings-directly `:print` strings directly in `nix repl` (cherry picked from commit 3539172fd2f7cee639ce46423c58beca4231f2db) Change-Id: I1972f3bf3b56312851f38288509d371d37f21677 Upstream-PR: https://github.com/NixOS/nix/pull/10208 --- src/libcmd/repl.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/libcmd/repl.cc') diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 0d7ad63a7..ee3a6e268 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -412,6 +412,7 @@ ProcessLineResult NixRepl::processLine(std::string line) << " :l, :load Load Nix expression and add it to scope\n" << " :lf, :load-flake Load Nix flake and add it to scope\n" << " :p, :print Evaluate and print expression recursively\n" + << " Strings are printed directly, without escaping.\n" << " :q, :quit Exit nix-repl\n" << " :r, :reload Reload all files\n" << " :sh Build dependencies of derivation, then start\n" @@ -619,7 +620,11 @@ ProcessLineResult NixRepl::processLine(std::string line) else if (command == ":p" || command == ":print") { Value v; evalString(arg, v); - printValue(std::cout, v); + if (v.type() == nString) { + std::cout << v.string.s; + } else { + printValue(std::cout, v); + } std::cout << std::endl; } -- cgit v1.2.3