From 1df2a6431fa1b51b9779070ce2a0171208985bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Mon, 14 Mar 2016 10:57:08 +0100 Subject: [PATCH] xdg-utils: replace commands more precisely Fix #13904, close #13908. Previously many messages got clobbered. Now it should be better. The solution is still relatively hacky, but I don't see how to improve it without doing lots of work. --- pkgs/tools/X11/xdg-utils/default.nix | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pkgs/tools/X11/xdg-utils/default.nix b/pkgs/tools/X11/xdg-utils/default.nix index 23b406c2d43f..6f1335593621 100644 --- a/pkgs/tools/X11/xdg-utils/default.nix +++ b/pkgs/tools/X11/xdg-utils/default.nix @@ -28,18 +28,17 @@ stdenv.mkDerivation rec { postInstall = stdenv.lib.optionalString mimiSupport '' cp ${mimisrc}/xdg-open $out/bin/xdg-open - substituteInPlace $out/bin/xdg-open --replace "awk " "${gawk}/bin/awk " - substituteInPlace $out/bin/xdg-open --replace "sort " "${coreutils}/bin/sort " - substituteInPlace $out/bin/xdg-open --replace "(file " "(${file}/bin/file " - '' + '' - for item in $out/bin/*; do - substituteInPlace $item --replace "cut " "${coreutils}/bin/cut " - substituteInPlace $item --replace "sed " "${gnused}/bin/sed " - substituteInPlace $item --replace "egrep " "${gnugrep}/bin/egrep " - sed -i $item -re "s#([^e])grep #\1${gnugrep}/bin/grep #g" # Don't replace 'egrep' - substituteInPlace $item --replace "which " "type -P " - substituteInPlace $item --replace "/usr/bin/file" "${file}/bin/file" + '' + + '' + for tool in "${coreutils}/bin/cut" "${gnused}/bin/sed" \ + "${gnugrep}"/bin/{e,}grep "${file}/bin/file" \ + ${stdenv.lib.optionalString mimiSupport + '' "${gawk}/bin/awk" "${coreutils}/bin/sort" ''} ; + do + sed "s# $(basename "$tool") # $tool #g" -i "$out"/bin/* done + + sed 's# which # type -P #g' -i "$out"/bin/* ''; meta = with stdenv.lib; {