parallel: --hashbang alias for --shebang.

sql: .dburl.aliases -> .sql/aliases.
unittest passes.
This commit is contained in:
Ole Tange 2010-09-08 01:43:11 +02:00
parent 0a5434c071
commit 20eab02de2
6 changed files with 50 additions and 13 deletions

View file

@ -6,6 +6,11 @@ dburl = null
sqlite2 sqlite3 support sqlite2 sqlite3 support
parallel: --hashbang alias for --shebang.
sql: .dburl.aliases -> .sql/aliases.
unittest passes.
== FEX == == FEX ==
fex syntax for splitting fields fex syntax for splitting fields

View file

@ -851,6 +851,8 @@ Exit if the size (see the B<-s> option) is exceeded.
=item B<--shebang> =item B<--shebang>
=item B<--hashbang>
=item B<-Y> =item B<-Y>
GNU B<Parallel> can be called as a shebang (#!) command as the first line of a script. Like this: GNU B<Parallel> 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'; $Global::trim = 'n';
# This must be done first as this may exec myself # 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 # Program is called from #! line in script
$ARGV[0]=~s/^-Y //; # remove -Y if on its own $ARGV[0]=~s/^-Y //; # remove -Y if on its own
$ARGV[0]=~s/^-Y/-/; # remove -Y if bundled with other options $ARGV[0]=~s/^-Y/-/; # remove -Y if bundled with other options
$ARGV[0]=~s/^--shebang //; # remove --shebang if it is set $ARGV[0]=~s/^--shebang //; # remove --shebang if it is set
$ARGV[0]=~s/^--hashbang //; # remove --hashbang if it is set
my $argfile = pop @ARGV; my $argfile = pop @ARGV;
# exec myself to split @ARGV into separate fields # exec myself to split @ARGV into separate fields
exec "$0 --skip-first-line -a $argfile @ARGV"; exec "$0 --skip-first-line -a $argfile @ARGV";
@ -2306,7 +2310,7 @@ sub parse_options {
"bg" => \$::opt_bg, "bg" => \$::opt_bg,
"wait" => \$::opt_wait, "wait" => \$::opt_wait,
# Shebang #!/usr/bin/parallel -Yotheroptions # Shebang #!/usr/bin/parallel -Yotheroptions
"Y|shebang" => \$::opt_shebang, "Y|shebang|hashbang" => \$::opt_shebang,
"skip-first-line" => \$::opt_skip_first_line, "skip-first-line" => \$::opt_skip_first_line,
) || die_usage(); ) || die_usage();
$Global::debug = (defined $::opt_D); $Global::debug = (defined $::opt_D);

View file

@ -44,9 +44,9 @@ sql mysql:///tange </tmp/unittest.sql
echo '### Test dburl with username password host port' echo '### Test dburl with username password host port'
sql mysql://sqlunittest:CB5A1FFFA5A@localhost:3306/sqlunittest </tmp/unittest.sql sql mysql://sqlunittest:CB5A1FFFA5A@localhost:3306/sqlunittest </tmp/unittest.sql
echo "### Test .dburl.aliases" echo "### Test .sql/aliases"
echo :sqlunittest mysql://sqlunittest:CB5A1FFFA5A@localhost:3306/sqlunittest >> ~/.dburl.aliases echo :sqlunittest mysql://sqlunittest:CB5A1FFFA5A@localhost:3306/sqlunittest >> ~/.sql/aliases
sql :sqlunittest "SELECT 'Yes it does' as 'Test if .dburl.aliases works';" sql :sqlunittest "SELECT 'Yes it does' as 'Test if .sql/aliases works';"
echo "### Test --noheaders --no-headers -n" echo "### Test --noheaders --no-headers -n"
sql -n :sqlunittest 'select * from unittest order by id' \ sql -n :sqlunittest 'select * from unittest order by id' \
@ -71,9 +71,9 @@ sql --html mysql:///tange 'select * from unittest'
echo echo
echo "### Test --show-processlist|proclist|listproc"; echo "### Test --show-processlist|proclist|listproc";
sql --show-processlist :sqlunittest | wc sql --show-processlist :sqlunittest | wc -lw
sql --proclist :sqlunittest | wc sql --proclist :sqlunittest | wc -lw
sql --listproc :sqlunittest | wc sql --listproc :sqlunittest | wc -lw
echo "### Test --db-size --dbsize"; echo "### Test --db-size --dbsize";
sql --dbsize :sqlunittest | wc sql --dbsize :sqlunittest | wc

View file

@ -10,6 +10,26 @@ EOF
chmod 755 /tmp/shebang chmod 755 /tmp/shebang
/tmp/shebang /tmp/shebang
echo '### Test of #! --shebang'
cat >/tmp/shebang <<EOF
#!/usr/local/bin/parallel --shebang -rk echo
A
B
C
EOF
chmod 755 /tmp/shebang
/tmp/shebang
echo '### Test of #! --hashbang'
cat >/tmp/shebang <<EOF
#!/usr/local/bin/parallel --hashbang -rk echo
A
B
C
EOF
chmod 755 /tmp/shebang
/tmp/shebang
echo '### Test of #! with 2 files as input' echo '### Test of #! with 2 files as input'
cat >/tmp/shebang <<EOF cat >/tmp/shebang <<EOF
#!/usr/local/bin/parallel -Yrk -a /tmp/123 echo #!/usr/local/bin/parallel -Yrk -a /tmp/123 echo

View file

@ -13,8 +13,8 @@ Yes it does
### Test dburl with username password host port ### Test dburl with username password host port
Test reading SQL from file works Test reading SQL from file works
Yes it does Yes it does
### Test .dburl.aliases ### Test .sql/aliases
Test if .dburl.aliases works Test if .sql/aliases works
Yes it does Yes it does
### Test --noheaders --no-headers -n ### Test --noheaders --no-headers -n
abc 1 abc 1
@ -32,9 +32,9 @@ def 3
### Test --html ### Test --html
<TABLE BORDER=1><TR><TH>id</TH><TH>data</TH></TR><TR><TD>1</TD><TD>abc</TD></TR><TR><TD>3</TD><TD>def</TD></TR></TABLE> <TABLE BORDER=1><TR><TH>id</TH><TH>data</TH></TR><TR><TD>1</TD><TD>abc</TD></TR><TR><TD>3</TD><TD>def</TD></TR></TABLE>
### Test --show-processlist|proclist|listproc ### Test --show-processlist|proclist|listproc
2 17 108 2 17
2 17 108 2 17
2 17 108 2 17
### Test --db-size --dbsize ### Test --db-size --dbsize
3 12 89 3 12 89
3 12 89 3 12 89

View file

@ -2,6 +2,14 @@
A A
B B
C C
### Test of #! --shebang
A
B
C
### Test of #! --hashbang
A
B
C
### Test of #! with 2 files as input ### Test of #! with 2 files as input
A 1 A 1
B 2 B 2