Skip to content

Commit

Permalink
parallel: fix calculation of max line length
Browse files Browse the repository at this point in the history
parallel >= 20200822 uses /bin/echo to calculate the max allowed line
length. Patch it to a correct path, so that it doesn't (silently) fail
and fall back to a low value of 324.

Before:
  $ parallel --max-line-length-allowed
  324

After:
  $ parallel --max-line-length-allowed
  131063

Fixes: 16ca872 ("parallel: 20200722 -> 20200822")
  • Loading branch information
bjornfor committed Oct 24, 2020
1 parent c0a646e commit 3d4e133
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkgs/tools/misc/parallel/default.nix
@@ -1,4 +1,4 @@
{ fetchurl, stdenv, perl, makeWrapper, procps }:
{ fetchurl, stdenv, perl, makeWrapper, procps, coreutils }:

stdenv.mkDerivation rec {
name = "parallel-20200822";
Expand All @@ -8,6 +8,14 @@ stdenv.mkDerivation rec {
sha256 = "02dy46g6f05p7s2qs8h6yg20p1zl3flxxf77n5jw74l3h1m24m4n";
};

patches = [
./fix-max-line-length-allowed.diff
];

postPatch = ''
substituteInPlace src/parallel --subst-var-by coreutils ${coreutils}
'';

outputs = [ "out" "man" ];

nativeBuildInputs = [ makeWrapper ];
Expand Down
17 changes: 17 additions & 0 deletions pkgs/tools/misc/parallel/fix-max-line-length-allowed.diff
@@ -0,0 +1,17 @@
Correct path to coreutils echo to fix parallel --max-line-length-allowed.

Author: Bjørn Forsman

diff --git a/src/parallel b/src/parallel
index a047fd94..9fc5f671 100755
--- a/src/parallel
+++ b/src/parallel
@@ -11580,7 +11580,7 @@ sub is_acceptable_command_line_length($$) {
$len += length $Global::parallel_env;
}
# Force using non-built-in command
- ::qqx("/bin/echo ".${string}x(($len-length "/bin/echo ")/length $string));
+ ::qqx("@coreutils@/bin/echo ".${string}x(($len-length "@coreutils@/bin/echo ")/length $string));
::debug("init", "$len=$? ");
return not $?;
}

0 comments on commit 3d4e133

Please sign in to comment.