Unittest: -0 on filenames ending in \n

This commit is contained in:
Ole Tange 2010-07-09 15:24:24 +02:00
parent 3b8e04b91b
commit 555436f746
3 changed files with 12 additions and 9 deletions

View file

@ -1,5 +1,3 @@
Unittest: -0 on filenames ending in \n
# Hvordan udregnes system limits på remote systems hvis jeg ikke ved, hvormange # 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 # argumenter, der er? Lav system limits lokalt og lad det være max

View file

@ -1204,7 +1204,7 @@ optimized for using B<NUL> as separator but are optimized for
B<newline> as separator. E.g B<head>, B<tail>, B<awk>, B<ls>, B<echo>, B<newline> as separator. E.g B<head>, B<tail>, B<awk>, B<ls>, B<echo>,
B<sed>, B<tar -v>, B<perl> (B<-0> and \0 instead of \n), B<locate> B<sed>, B<tar -v>, B<perl> (B<-0> and \0 instead of \n), B<locate>
(requires using B<-0>), B<find> (requires using B<-print0>), B<grep> (requires using B<-0>), B<find> (requires using B<-print0>), B<grep>
(requires user to use B<-z> or B<-Z>). (requires user to use B<-z> or B<-Z>), B<sort> (requires using B<-z>).
So GNU B<parallel>'s newline separation can be emulated with: So GNU B<parallel>'s newline separation can be emulated with:

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
PAR=parallel
rm -rf tmp 2>/dev/null rm -rf tmp 2>/dev/null
cd input-files cd input-files
tar xjf random_dirs_no_newline.tar.bz2 tar xjf random_dirs_no_newline.tar.bz2
@ -9,27 +7,34 @@ cd ..
cp -a input-files/random_dirs_no_newline tmp cp -a input-files/random_dirs_no_newline tmp
cd tmp cd tmp
# tests if special dir names causes problems echo '### Tests if special dir names causes problems'
ls | $PAR -v touch -- {}/abc-{}-{} 2>&1 | perl -e 'print sort (<>)' | md5sum ls | parallel -v touch -- {}/abc-{}-{} 2>&1 | perl -e 'print sort (<>)' | md5sum
echo -n 'There are ' echo -n 'There are '
find . -type d -print0 | perl -0 -ne '$a++;END{print $a}' find . -type d -print0 | perl -0 -ne '$a++;END{print $a}'
echo -n ' dirs with ' echo -n ' dirs with '
find . -type f -print0 | perl -0 -ne '$a++;END{print $a}' find . -type f -print0 | perl -0 -ne '$a++;END{print $a}'
echo ' files' echo ' files'
echo 'Removing 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 ' echo -n 'There are '
find . -type d -print0 | perl -0 -ne '$a++;END{print $a}' find . -type d -print0 | perl -0 -ne '$a++;END{print $a}'
echo -n ' dirs with ' echo -n ' dirs with '
find . -type f -print0 | perl -0 -ne '$a++;END{print $a}' find . -type f -print0 | perl -0 -ne '$a++;END{print $a}'
echo ' files' echo ' files'
echo 'Removing dirs' 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 ' echo -n 'There are '
find . -type d -print0 | perl -0 -ne '$a++;END{print $a}' find . -type d -print0 | perl -0 -ne '$a++;END{print $a}'
echo -n ' dirs with ' echo -n ' dirs with '
find . -type f -print0 | perl -0 -ne '$a++;END{print $a}' find . -type f -print0 | perl -0 -ne '$a++;END{print $a}'
echo ' files' 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 .. cd ..
rm -rf tmp rm -rf tmp