From 555436f7461624a0f61a05330e84ee8e117b05b9 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Fri, 9 Jul 2010 15:24:24 +0200 Subject: [PATCH] Unittest: -0 on filenames ending in \n --- doc/FUTURE_IDEAS | 2 -- src/parallel | 2 +- unittest/tests-to-run/test04.sh | 17 +++++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/doc/FUTURE_IDEAS b/doc/FUTURE_IDEAS index 24d81b81..eca9abe1 100644 --- a/doc/FUTURE_IDEAS +++ b/doc/FUTURE_IDEAS @@ -1,5 +1,3 @@ -Unittest: -0 on filenames ending in \n - # Hvordan udregnes system limits på remote systems hvis jeg ikke ved, hvormange # argumenter, der er? Lav system limits lokalt og lad det være max diff --git a/src/parallel b/src/parallel index 1330fed3..79909a82 100755 --- a/src/parallel +++ b/src/parallel @@ -1204,7 +1204,7 @@ optimized for using B as separator but are optimized for B as separator. E.g B, B, B, B, B, B, B, B (B<-0> and \0 instead of \n), B (requires using B<-0>), B (requires using B<-print0>), B -(requires user to use B<-z> or B<-Z>). +(requires user to use B<-z> or B<-Z>), B (requires using B<-z>). So GNU B's newline separation can be emulated with: diff --git a/unittest/tests-to-run/test04.sh b/unittest/tests-to-run/test04.sh index e0617878..04cbdd2a 100755 --- a/unittest/tests-to-run/test04.sh +++ b/unittest/tests-to-run/test04.sh @@ -1,7 +1,5 @@ #!/bin/bash -PAR=parallel - rm -rf tmp 2>/dev/null cd input-files tar xjf random_dirs_no_newline.tar.bz2 @@ -9,27 +7,34 @@ cd .. cp -a input-files/random_dirs_no_newline tmp cd tmp -# tests if special dir names causes problems -ls | $PAR -v touch -- {}/abc-{}-{} 2>&1 | perl -e 'print sort (<>)' | md5sum +echo '### Tests if special dir names causes problems' +ls | parallel -v touch -- {}/abc-{}-{} 2>&1 | perl -e 'print sort (<>)' | md5sum echo -n 'There are ' find . -type d -print0 | perl -0 -ne '$a++;END{print $a}' echo -n ' dirs with ' find . -type f -print0 | perl -0 -ne '$a++;END{print $a}' echo ' files' echo 'Removing files' -ls | $PAR -v rm -- {}/abc-{}-{} 2>&1 | perl -e 'print sort (<>)' | md5sum +ls | parallel -v rm -- {}/abc-{}-{} 2>&1 | perl -e 'print sort (<>)' | md5sum echo -n 'There are ' find . -type d -print0 | perl -0 -ne '$a++;END{print $a}' echo -n ' dirs with ' find . -type f -print0 | perl -0 -ne '$a++;END{print $a}' echo ' files' echo 'Removing dirs' -ls | $PAR -v rmdir -- {} 2>&1 | perl -e 'print sort (<>)' | md5sum +ls | parallel -v rmdir -- {} 2>&1 | perl -e 'print sort (<>)' | md5sum echo -n 'There are ' find . -type d -print0 | perl -0 -ne '$a++;END{print $a}' echo -n ' dirs with ' find . -type f -print0 | perl -0 -ne '$a++;END{print $a}' echo ' files' +echo '### Tests name ending in \n causes problems' +echo newline1 >'newline1 +' +echo newline2 >'newline2 +' +find newli* -print0 | parallel -0 cat {} ">" {}.bak +find newli* -print0 | sort -z cd .. rm -rf tmp