parallel: --plus bug if input ended in .

This commit is contained in:
Ole Tange 2022-08-19 23:42:55 +02:00
parent b74f2d5629
commit 6097ff9de7
6 changed files with 32 additions and 16 deletions

View file

@ -2703,8 +2703,8 @@ sub init_globals() {
'{//}' =>
('$Global::use{"File::Basename"} ||= eval "use File::Basename; 1;"; '.
'$_ = dirname($_);'),
'{/.}' => 's:.*/::; s:\.[^/.]+$::;',
'{.}' => 's:\.[^/.]+$::',
'{/.}' => 's:.*/::; s:\.[^/.]*$::;',
'{.}' => 's:\.[^/.]*$::',
);
%Global::plus =
(
@ -2716,12 +2716,12 @@ sub init_globals() {
# a.b => b; a => ''
'{+.}' => 's:.*\.:: || s:.*$::',
# a.b.c => b.c; a.b => ''; a => ''
'{+..}' => 's:.*\.([^/.]+\.[^/.]+)$:$1: || s:.*$::',
'{+...}' => 's:.*\.([^/.]+\.[^/.]+\.[^/.]+)$:$1: || s:.*$::',
'{..}' => 's:\.[^/.]+\.[^/.]+$::',
'{...}' => 's:\.[^/.]+\.[^/.]+\.[^/.]+$::',
'{/..}' => 's:.*/::; s:\.[^/.]+\.[^/.]+$::',
'{/...}' => 's:.*/::; s:\.[^/.]+\.[^/.]+\.[^/.]+$::',
'{+..}' => 's:.*\.([^/.]*\.[^/.]*)$:$1: || s:.*$::',
'{+...}' => 's:.*\.([^/.]*\.[^/.]*\.[^/.]*)$:$1: || s:.*$::',
'{..}' => 's:\.[^/.]*\.[^/.]*$::',
'{...}' => 's:\.[^/.]*\.[^/.]*\.[^/.]*$::',
'{/..}' => 's:.*/::; s:\.[^/.]*\.[^/.]*$::',
'{/...}' => 's:.*/::; s:\.[^/.]*\.[^/.]*\.[^/.]*$::',
# n choose k = Binomial coefficient
'{choose_k}' => ('for $t (2..$#arg)'.
'{ if($arg[$t-1] ge $arg[$t]) { skip() } }'),

View file

@ -14,7 +14,10 @@ par_plus() {
parallel -k --plus echo {} = {+/}/{/} = {.}.{+.} = {+/}/{/.}.{+.} = \
{..}.{+..} = {+/}/{/..}.{+..} = {...}.{+...} = \
{+/}/{/...}.{+...} \
::: a a.b a.b.c a.b.c.d a/1 a.b/1.2 a.b.c/1.2.3 a.b.c.d/1.2.3.4
::: a a.b a.b.c a.b.c.d a/1 a.b/1.2 a.b.c/1.2.3 a.b.c.d/1.2.3.4 \
a. a.b. a.b.c. a.b.c.d. a/1. a.b/1.2. a.b.c/1.2.3. a.b.c.d/1.2.3.4. \
a.. a.b.. a.b.c.. a.b.c.d.. a./1. a.b./1.2.. \
a.b.c./1.2.3.. a.b.c.d./1.2.3.4.. \
echo '### Test {%...} {%%...} {#...} {##...}'
a=z.z.z.foo

View file

@ -43,7 +43,7 @@ par_influx() {
echo INSERT cpu,host=serverA,region=us_west value=0.65;
echo 'select * from cpu' ) |
sql influx:///parallel
sql --show-tables influx:///parallel
sql --show-tables influx:///parallel | grep parallel;
sql influx:///parallel 'SELECT * FROM cpu;'
sql influx:///parallel 'SELECT "host", "region", "value" FROM "cpu"'
sql --pretty influx:///parallel 'SELECT * FROM cpu;'

View file

@ -442,6 +442,22 @@ par_plus a/1 = a/1 = a/1. = a/1. = a/1. = a/1. = a/1. = a/1.
par_plus a.b/1.2 = a.b/1.2 = a.b/1.2 = a.b/1.2 = a.b/1.2. = a.b/1.2. = a.b/1.2. = a.b/1.2.
par_plus a.b.c/1.2.3 = a.b.c/1.2.3 = a.b.c/1.2.3 = a.b.c/1.2.3 = a.b.c/1.2.3 = a.b.c/1.2.3 = a.b.c/1.2.3. = a.b.c/1.2.3.
par_plus a.b.c.d/1.2.3.4 = a.b.c.d/1.2.3.4 = a.b.c.d/1.2.3.4 = a.b.c.d/1.2.3.4 = a.b.c.d/1.2.3.4 = a.b.c.d/1.2.3.4 = a.b.c.d/1.2.3.4 = a.b.c.d/1.2.3.4
par_plus a. = /a. = a. = /a. = a.. = /a.. = a.. = /a..
par_plus a.b. = /a.b. = a.b. = /a.b. = a.b. = /a.b. = a.b.. = /a.b..
par_plus a.b.c. = /a.b.c. = a.b.c. = /a.b.c. = a.b.c. = /a.b.c. = a.b.c. = /a.b.c.
par_plus a.b.c.d. = /a.b.c.d. = a.b.c.d. = /a.b.c.d. = a.b.c.d. = /a.b.c.d. = a.b.c.d. = /a.b.c.d.
par_plus a/1. = a/1. = a/1. = a/1. = a/1.. = a/1.. = a/1.. = a/1..
par_plus a.b/1.2. = a.b/1.2. = a.b/1.2. = a.b/1.2. = a.b/1.2. = a.b/1.2. = a.b/1.2.. = a.b/1.2..
par_plus a.b.c/1.2.3. = a.b.c/1.2.3. = a.b.c/1.2.3. = a.b.c/1.2.3. = a.b.c/1.2.3. = a.b.c/1.2.3. = a.b.c/1.2.3. = a.b.c/1.2.3.
par_plus a.b.c.d/1.2.3.4. = a.b.c.d/1.2.3.4. = a.b.c.d/1.2.3.4. = a.b.c.d/1.2.3.4. = a.b.c.d/1.2.3.4. = a.b.c.d/1.2.3.4. = a.b.c.d/1.2.3.4. = a.b.c.d/1.2.3.4.
par_plus a.. = /a.. = a.. = /a.. = a.. = /a.. = a... = /a...
par_plus a.b.. = /a.b.. = a.b.. = /a.b.. = a.b.. = /a.b.. = a.b.. = /a.b..
par_plus a.b.c.. = /a.b.c.. = a.b.c.. = /a.b.c.. = a.b.c.. = /a.b.c.. = a.b.c.. = /a.b.c..
par_plus a.b.c.d.. = /a.b.c.d.. = a.b.c.d.. = /a.b.c.d.. = a.b.c.d.. = /a.b.c.d.. = a.b.c.d.. = /a.b.c.d..
par_plus a./1. = a./1. = a./1. = a./1. = a./1.. = a./1.. = a./1.. = a./1..
par_plus a.b./1.2.. = a.b./1.2.. = a.b./1.2.. = a.b./1.2.. = a.b./1.2.. = a.b./1.2.. = a.b./1.2.. = a.b./1.2..
par_plus a.b.c./1.2.3.. = a.b.c./1.2.3.. = a.b.c./1.2.3.. = a.b.c./1.2.3.. = a.b.c./1.2.3.. = a.b.c./1.2.3.. = a.b.c./1.2.3.. = a.b.c./1.2.3..
par_plus a.b.c.d./1.2.3.4.. = a.b.c.d./1.2.3.4.. = a.b.c.d./1.2.3.4.. = a.b.c.d./1.2.3.4.. = a.b.c.d./1.2.3.4.. = a.b.c.d./1.2.3.4.. = a.b.c.d./1.2.3.4.. = a.b.c.d./1.2.3.4..
par_plus ### Test {%...} {%%...} {#...} {##...}
par_plus z.foo
par_plus z.foo

View file

@ -42,8 +42,8 @@ def 3
6
6
### Test --table-size --tablesize
82
82
90
90
### Test --debug
dburl mysql://tange:tange@localhost:3306/tange
databasedriver mysql user tange password tange host localhost port 3306 database tange query

View file

@ -9,16 +9,13 @@ par_influx name
par_influx ----
par_influx _internal
par_influx mydb
par_influx myinflux
par_influx parallel
par_influx name: cpu
par_influx time host region value
par_influx ---- ---- ------ -----
par_influx 0000000000000000000 serverA us_west 0.00
par_influx 0000000000000000000 serverA us_west 0.00
par_influx name: measurements
par_influx name
par_influx ----
par_influx cpu
par_influx name: cpu
par_influx time host region value
par_influx ---- ---- ------ -----