basenamereplace and basenameextensionreplace activated.

Testsuite of {/} {/.} {#/.} {#/}.
This commit is contained in:
Ole Tange 2010-12-03 00:04:12 +01:00
parent 69e7da5bff
commit 77f83e6270
7 changed files with 120 additions and 28 deletions

View file

@ -25,6 +25,12 @@ http://nd.gd/0s http://www.youtube.com/watch?v=OpaiGYxkSuQ
http://nd.gd/0t http://en.wikipedia.org/wiki/Xargs#The_separator_problem
http://nd.gd/3k http://www.gnu.org/software/parallel/man.html#differences_between_xargs_and_gnu_parallel
If you like xargs you may love GNU Parallel: http://nd.gd/0s
With GNU Parallel (http://nd.gd/0s) you can do:
ls | grep jpeg | parallel mv {} {.}.jpg
Watch the intro video for GNU Parallel: http://nd.gd/0s
If your input file names are generated by users, you need to deal with

View file

@ -81,8 +81,9 @@ Content from release mail:
https://savannah.gnu.org/news/submit.php?group=parallel
https://savannah.gnu.org/news/approve.php?group=parallel
doc/pod2savannah_publicinfo src/parallel | klipper-stdin
https://savannah.gnu.org/project/admin/editgroupinfo.php?group=parallel
# No longer updated. Too long and too buggy
# doc/pod2savannah_publicinfo src/parallel | klipper-stdin
# https://savannah.gnu.org/project/admin/editgroupinfo.php?group=parallel
== Update website ==
@ -101,7 +102,7 @@ http://freshmeat.net/projects/parallel/releases/new
== Update Twitter ==
#GNU Parallel 20101113 released. See what is new in this release
New version of #GNU Parallel released. See what is new in this release
http://nd.gd/2j Watch the intro video http://nd.gd/0s
https://savannah.gnu.org/news/?group=parallel

View file

@ -1,7 +1,5 @@
all:
# cd ../debian/ && make
# cp ../debian/parallel_*.dsc ../debian/parallel_*.tar.gz home\:tange/parallel/
cd ../debian/ && make
cp ../debian/parallel_*.dsc ../debian/parallel_*.tar.gz home\:tange/parallel/
cp `ls ../../parallel-*.tar.bz2|tail -n1` home\:tange/parallel/
cd home\:tange/parallel/ && osc up && osc add *.dsc *.tar.gz && osc ci
cd home\:tange/parallel/ && osc up && osc add *.dsc *.tar.gz *.spec *.tar.bz2 && osc ci

View file

@ -1 +1,4 @@
https://build.opensuse.org/package/show?package=parallel&project=home%3Atange
make
Edit parallel.spec
Then go to https://build.opensuse.org/package/files?package=parallel&project=home%3Atange
and add all the files

View file

@ -84,7 +84,7 @@ B<{.}> can be used the same places as B<{}>. The replacement string
B<{.}> can be changed with B<-U>.
=item B<{/}> (unimplemented)
=item B<{/}> (beta testing)
Basename of input line. This is a specialized replacement string
with the directory part removed.
@ -93,7 +93,7 @@ B<{/}> can be used the same places as B<{}>. The replacement string
B<{/}> can be changed with B<--basenamereplace>.
=item B<{/.}> (unimplemented)
=item B<{/.}> (beta testing)
Basename of input line without extension. This is a specialized
replacement string with the directory and extension part removed. It
@ -119,7 +119,7 @@ extension. It is a combination of B<{>I<n>B<}> and B<{.}>.
B<{>I<n>.B<}> can be used the same places as B<{>I<n>B<}>.
=item B<{>I<n>/B<}> (unimplemented)
=item B<{>I<n>/B<}> (beta testing)
Basename of argument from argument file I<n> or the I<n>'th argument.
It is a combination of B<{>I<n>B<}> and B<{/}>. See B<-a> and B<-N>.
@ -127,7 +127,7 @@ It is a combination of B<{>I<n>B<}> and B<{/}>. See B<-a> and B<-N>.
B<{>I<n>/B<}> can be used the same places as B<{>I<n>B<}>.
=item B<{>I<n>/.B<}> (unimplemented)
=item B<{>I<n>/.B<}> (beta testing)
Basename of argument from argument file I<n> or the I<n>'th argument
without extension. It is a combination of B<{>I<n>B<}>, B<{/}>, and
@ -191,7 +191,7 @@ B<{6}> will refer to the line with the same line number from the 6th
file.
=item B<--arg-file-sep> I<sep-str> (beta testing)
=item B<--arg-file-sep> I<sep-str>
Use I<sep-str> instead of B<::::> as separator string between command
and argument files. Useful if B<::::> is used for something else by the
@ -200,7 +200,7 @@ command.
See also: B<::::>.
=item B<--arg-sep> I<sep-str> (beta testing)
=item B<--arg-sep> I<sep-str>
Use I<sep-str> instead of B<:::> as separator string. Useful if B<:::>
is used for something else by the command.
@ -223,12 +223,12 @@ Multiple B<-B> can be specified to transfer more basefiles. The
I<file> will be transferred the same way as B<--transfer>.
=item B<--basenamereplace> I<replace-str> (unimplemented)
=item B<--basenamereplace> I<replace-str> (beta testing)
Use the replacement string I<replace-str> instead of B<{/}> for basename of input line.
=item B<--basenameextensionreplace> I<replace-str> (unimplemented)
=item B<--basenameextensionreplace> I<replace-str> (beta testing)
Use the replacement string I<replace-str> instead of B<{/.}> for basename of input line without extension.
@ -264,9 +264,9 @@ removed on the remote server. Directories created will not be removed
B<--cleanup> is ignored when not used with B<--transfer> or B<--return>.
=item B<--colsep> I<regexp> (beta testing)
=item B<--colsep> I<regexp>
=item B<-C> I<regexp> (beta testing)
=item B<-C> I<regexp>
Column separator. The input will be treated as a table with I<regexp>
separating the columns. The n'th column can be access using
@ -460,13 +460,13 @@ If the evaluated number is less than 1 then 1 will be used. See also
B<--use-cpus-instead-of-cores>.
=item B<--jobs> I<procfile> (beta test)
=item B<--jobs> I<procfile>
=item B<-j> I<procfile> (beta test)
=item B<-j> I<procfile>
=item B<--max-procs> I<procfile> (beta test)
=item B<--max-procs> I<procfile>
=item B<-P> I<procfile> (beta test)
=item B<-P> I<procfile>
Read parameter from file. Use the content of I<procfile> as parameter
for I<-j>. E.g. I<procfile> could contain the string 100% or +2 or
@ -558,9 +558,9 @@ GNU B<parallel> will exit.
Implies B<-X> unless B<-m> is set.
=item B<--max-replace-args>=I<max-args> (beta test)
=item B<--max-replace-args>=I<max-args>
=item B<-N> I<max-args> (beta test)
=item B<-N> I<max-args>
Use at most I<max-args> arguments per command line. Like B<-n> but
also makes replacement strings B<{1}> .. B<{>I<max-args>B<}> that
@ -696,7 +696,7 @@ operating system and the B<-s> option. Pipe the input from /dev/null
to do anything.
=item B<--semaphore> (beta testing)
=item B<--semaphore>
Work as a counting semaphore. B<--semaphore> will cause GNU
B<parallel> to start I<command> in the background. When the number of
@ -713,7 +713,7 @@ Used with B<--fg>, B<--wait>, and B<--semaphorename>.
The command B<sem> is an alias for B<parallel --semaphore>.
=item B<--semaphorename> I<name> (beta testing)
=item B<--semaphorename> I<name>
=item B<--id> I<name>
@ -844,7 +844,7 @@ Transfer, Return, Cleanup. Short hand for:
B<--transfer> B<--return> I<filename> B<--cleanup>
=item B<--trim> <n|l|r|lr|rl> (beta testing)
=item B<--trim> <n|l|r|lr|rl>
Trim white space in input.
@ -2578,6 +2578,8 @@ sub get_options_from_array {
"quote|q" => \$::opt_q,
"I=s" => \$::opt_I,
"extensionreplace|U=s" => \$::opt_U,
"basenamereplace=s" => \$::opt_basenamereplace,
"basenameextensionreplace=s" => \$::opt_basenameextensionreplace,
"jobs|j=s" => \$::opt_P,
"max-line-length-allowed" => \$::opt_max_line_length_allowed,
"number-of-cpus" => \$::opt_number_of_cpus,

View file

@ -0,0 +1,34 @@
#!/bin/bash
echo "### Test --basenamereplace"
parallel -k -X --basenamereplace FOO echo FOO ::: /a/b.c a/b.c b.c /a/b a/b b
parallel -k --basenamereplace FOO echo FOO ::: /a/b.c a/b.c b.c /a/b a/b b
echo "### Test --basenameextensionreplace"
parallel -k -X --basenameextensionreplace FOO echo FOO ::: /a/b.c a/b.c b.c /a/b a/b b
parallel -k --basenameextensionreplace FOO echo FOO ::: /a/b.c a/b.c b.c /a/b a/b b
echo "### Test {/}"
parallel -k -X echo {/} ::: /a/b.c a/b.c b.c /a/b a/b b
echo "### Test {/.}"
parallel -k -X echo {/.} ::: /a/b.c a/b.c b.c /a/b a/b b
echo "### Test {#/.}"
parallel -k -X echo {2/.} ::: /a/number1.c a/number2.c number3.c /a/number4 a/number5 number6
echo "### Test {#/}"
parallel -k -X echo {2/} ::: /a/number1.c a/number2.c number3.c /a/number4 a/number5 number6
echo "### Test {#.}"
parallel -k -X echo {2.} ::: /a/number1.c a/number2.c number3.c /a/number4 a/number5 number6
SERVER1=parallel-server3
SERVER2=parallel-server2
echo "### Test combined --return {/}_{/.}_{#/.}_{#/}_{#.}"
stdout parallel -k -Xv --cleanup --return tmp/{/}_{/.}_{2/.}_{2/}_{2.}/file -S parallel@$SERVER2 \
mkdir -p tmp/{/}_{/.}_{2/.}_{2/}_{2.} \;touch tmp/{/}_{/.}_{2/.}_{2/}_{2.}/file \
::: /a/number1.c a/number2.c number3.c /a/number4 a/number5 number6
find tmp
rm -rf tmp

View file

@ -0,0 +1,48 @@
### Test --basenamereplace
b.c b.c b.c b b b
b.c
b.c
b.c
b
b
b
### Test --basenameextensionreplace
b b b b b b
b
b
b
b
b
b
### Test {/}
b.c b.c b.c b b b
### Test {/.}
b b b b b b
### Test {#/.}
number2
### Test {#/}
number2.c
### Test {#.}
a/number2
### Test combined --return {/}_{/.}_{#/.}_{#/}_{#.}
Warning: using -X or -m with --sshlogin may fail
mkdir -p tmp/number1.c_number1_number2_number2.c_a/number2 tmp/number2.c_number2_number2_number2.c_a/number2 tmp/number3.c_number3_number2_number2.c_a/number2 tmp/number4_number4_number2_number2.c_a/number2 tmp/number5_number5_number2_number2.c_a/number2 tmp/number6_number6_number2_number2.c_a/number2 ;touch tmp/number1.c_number1_number2_number2.c_a/number2/file tmp/number2.c_number2_number2_number2.c_a/number2/file tmp/number3.c_number3_number2_number2.c_a/number2/file tmp/number4_number4_number2_number2.c_a/number2/file tmp/number5_number5_number2_number2.c_a/number2/file tmp/number6_number6_number2_number2.c_a/number2/file
tmp
tmp/number6_number6_number2_number2.c_a
tmp/number6_number6_number2_number2.c_a/number2
tmp/number6_number6_number2_number2.c_a/number2/file
tmp/number3.c_number3_number2_number2.c_a
tmp/number3.c_number3_number2_number2.c_a/number2
tmp/number3.c_number3_number2_number2.c_a/number2/file
tmp/number5_number5_number2_number2.c_a
tmp/number5_number5_number2_number2.c_a/number2
tmp/number5_number5_number2_number2.c_a/number2/file
tmp/number2.c_number2_number2_number2.c_a
tmp/number2.c_number2_number2_number2.c_a/number2
tmp/number2.c_number2_number2_number2.c_a/number2/file
tmp/number1.c_number1_number2_number2.c_a
tmp/number1.c_number1_number2_number2.c_a/number2
tmp/number1.c_number1_number2_number2.c_a/number2/file
tmp/number4_number4_number2_number2.c_a
tmp/number4_number4_number2_number2.c_a/number2
tmp/number4_number4_number2_number2.c_a/number2/file