From 20eab02de29e3c7805813279c00e7befbbbe37d4 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 8 Sep 2010 01:43:11 +0200 Subject: [PATCH] parallel: --hashbang alias for --shebang. sql: .dburl.aliases -> .sql/aliases. unittest passes. --- doc/FUTURE_IDEAS | 5 +++++ src/parallel | 8 ++++++-- unittest/tests-to-run/sql01.sh | 12 ++++++------ unittest/tests-to-run/test31.sh | 20 ++++++++++++++++++++ unittest/wanted-results/sql01 | 10 +++++----- unittest/wanted-results/test31 | 8 ++++++++ 6 files changed, 50 insertions(+), 13 deletions(-) diff --git a/doc/FUTURE_IDEAS b/doc/FUTURE_IDEAS index 0392431e..4a36a374 100644 --- a/doc/FUTURE_IDEAS +++ b/doc/FUTURE_IDEAS @@ -6,6 +6,11 @@ dburl = null sqlite2 sqlite3 support +parallel: --hashbang alias for --shebang. +sql: .dburl.aliases -> .sql/aliases. +unittest passes. + + == FEX == fex syntax for splitting fields diff --git a/src/parallel b/src/parallel index a21a18b2..b21ca985 100755 --- a/src/parallel +++ b/src/parallel @@ -851,6 +851,8 @@ Exit if the size (see the B<-s> option) is exceeded. =item B<--shebang> +=item B<--hashbang> + =item B<-Y> GNU B can be called as a shebang (#!) command as the first line of a script. Like this: @@ -2221,11 +2223,13 @@ sub parse_options { $Global::trim = 'n'; # This must be done first as this may exec myself - if(defined $ARGV[0] and ($ARGV[0]=~/^-Y/ or $ARGV[0]=~/^--shebang /)) { + if(defined $ARGV[0] and ($ARGV[0]=~/^-Y/ or $ARGV[0]=~/^--shebang / or + $ARGV[0]=~/^--hashbang /)) { # Program is called from #! line in script $ARGV[0]=~s/^-Y //; # remove -Y if on its own $ARGV[0]=~s/^-Y/-/; # remove -Y if bundled with other options $ARGV[0]=~s/^--shebang //; # remove --shebang if it is set + $ARGV[0]=~s/^--hashbang //; # remove --hashbang if it is set my $argfile = pop @ARGV; # exec myself to split @ARGV into separate fields exec "$0 --skip-first-line -a $argfile @ARGV"; @@ -2306,7 +2310,7 @@ sub parse_options { "bg" => \$::opt_bg, "wait" => \$::opt_wait, # Shebang #!/usr/bin/parallel -Yotheroptions - "Y|shebang" => \$::opt_shebang, + "Y|shebang|hashbang" => \$::opt_shebang, "skip-first-line" => \$::opt_skip_first_line, ) || die_usage(); $Global::debug = (defined $::opt_D); diff --git a/unittest/tests-to-run/sql01.sh b/unittest/tests-to-run/sql01.sh index 144fc223..43908b07 100755 --- a/unittest/tests-to-run/sql01.sh +++ b/unittest/tests-to-run/sql01.sh @@ -44,9 +44,9 @@ sql mysql:///tange > ~/.dburl.aliases -sql :sqlunittest "SELECT 'Yes it does' as 'Test if .dburl.aliases works';" +echo "### Test .sql/aliases" +echo :sqlunittest mysql://sqlunittest:CB5A1FFFA5A@localhost:3306/sqlunittest >> ~/.sql/aliases +sql :sqlunittest "SELECT 'Yes it does' as 'Test if .sql/aliases works';" echo "### Test --noheaders --no-headers -n" sql -n :sqlunittest 'select * from unittest order by id' \ @@ -71,9 +71,9 @@ sql --html mysql:///tange 'select * from unittest' echo echo "### Test --show-processlist|proclist|listproc"; -sql --show-processlist :sqlunittest | wc -sql --proclist :sqlunittest | wc -sql --listproc :sqlunittest | wc +sql --show-processlist :sqlunittest | wc -lw +sql --proclist :sqlunittest | wc -lw +sql --listproc :sqlunittest | wc -lw echo "### Test --db-size --dbsize"; sql --dbsize :sqlunittest | wc diff --git a/unittest/tests-to-run/test31.sh b/unittest/tests-to-run/test31.sh index 782ed423..3260a265 100644 --- a/unittest/tests-to-run/test31.sh +++ b/unittest/tests-to-run/test31.sh @@ -10,6 +10,26 @@ EOF chmod 755 /tmp/shebang /tmp/shebang +echo '### Test of #! --shebang' +cat >/tmp/shebang </tmp/shebang </tmp/shebang <iddata1abc3def ### Test --show-processlist|proclist|listproc - 2 17 108 - 2 17 108 - 2 17 108 + 2 17 + 2 17 + 2 17 ### Test --db-size --dbsize 3 12 89 3 12 89 diff --git a/unittest/wanted-results/test31 b/unittest/wanted-results/test31 index 2099d8c5..858bef9e 100644 --- a/unittest/wanted-results/test31 +++ b/unittest/wanted-results/test31 @@ -2,6 +2,14 @@ A B C +### Test of #! --shebang +A +B +C +### Test of #! --hashbang +A +B +C ### Test of #! with 2 files as input A 1 B 2