parallel: Warn if the first 3 values end in \r\n (DOS newline).

This commit is contained in:
Ole Tange 2021-02-17 16:09:50 +01:00
parent c7d42df6c6
commit f44eb31be6

View file

@ -2155,7 +2155,7 @@ sub check_invalid_option_combinations() {
sub init_globals() { sub init_globals() {
# Defaults: # Defaults:
$Global::version = 20210201; $Global::version = 20210202;
$Global::progname = 'parallel'; $Global::progname = 'parallel';
$::name = "GNU Parallel"; $::name = "GNU Parallel";
$Global::infinity = 2**31; $Global::infinity = 2**31;
@ -3464,7 +3464,9 @@ sub init_run_jobs() {
::usleep(rand()*300); ::usleep(rand()*300);
::warning("No more processes: ". ::warning("No more processes: ".
"Decreasing number of running jobs to $max.", "Decreasing number of running jobs to $max.",
"Raising ulimit -u or /etc/security/limits.conf may help."); "Try increasing 'ulimit -u' (try: ulimit -u `ulimit -Hu`)",
"or increasing 'nproc' in /etc/security/limits.conf",
"or increasing /proc/sys/kernel/pid_max");
return 0; return 0;
} }
} }
@ -3472,7 +3474,10 @@ sub init_run_jobs() {
# No more file handles # No more file handles
$no_more_file_handles_warned++ or $no_more_file_handles_warned++ or
::warning("No more file handles. ", ::warning("No more file handles. ",
"Raising ulimit -n or /etc/security/limits.conf may help."); "Try running 'parallel -j0 -N 100 --pipe parallel -j0'",
"or increasing 'ulimit -n' (try: ulimit -n `ulimit -Hn`)",
"or increasing 'nofile' in /etc/security/limits.conf",
"or increasing /proc/sys/fs/file-max");
debug("start", "No more file handles. "); debug("start", "No more file handles. ");
return 0; return 0;
} }
@ -11553,7 +11558,6 @@ sub new($) {
} }
} }
} }
# Add {} if no replacement strings in @command # Add {} if no replacement strings in @command
($replacecount_ref, $len_ref, @command) = ($replacecount_ref, $len_ref, @command) =
replacement_counts_and_lengths($transfer_files,$return_files,@command); replacement_counts_and_lengths($transfer_files,$return_files,@command);
@ -12297,7 +12301,11 @@ sub nest_get($) {
return shift @{$self->{'unget'}}; return shift @{$self->{'unget'}};
} }
sub read_arg_from_fh($) { {
my $cr_count = 0;
my $nl_count = 0;
my $dos_crnl_determined;
sub read_arg_from_fh($) {
# Read one Arg from filehandle # Read one Arg from filehandle
# Returns: # Returns:
# Arg-object with one read line # Arg-object with one read line
@ -12315,6 +12323,20 @@ sub read_arg_from_fh($) {
return undef; return undef;
} }
} }
if(not $dos_crnl_determined and not $opt::d) {
# Warn if input has CR-NL and -d is not set
if($arg =~ /\r$/) {
$cr_count++;
} else {
$nl_count++;
}
if($cr_count == 3 or $nl_count == 3) {
$dos_crnl_determined = 1;
if($nl_count == 0 and $cr_count == 3) {
::warning('The first three values end in CR-NL. Consider using -d "\r\n"');
}
}
}
if($opt::csv) { if($opt::csv) {
# We need to read a full CSV line. # We need to read a full CSV line.
if(($arg =~ y/"/"/) % 2 ) { if(($arg =~ y/"/"/) % 2 ) {
@ -12368,6 +12390,7 @@ sub read_arg_from_fh($) {
} else { } else {
::die_bug("multiread arg undefined"); ::die_bug("multiread arg undefined");
} }
}
} }
# Prototype forwarding # Prototype forwarding