mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 14:07:55 +00:00
parallel: --hashbang alias for --shebang.
sql: .dburl.aliases -> .sql/aliases. unittest passes.
This commit is contained in:
parent
0a5434c071
commit
20eab02de2
|
@ -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
|
||||
|
|
|
@ -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<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';
|
||||
|
||||
# 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);
|
||||
|
|
|
@ -44,9 +44,9 @@ sql mysql:///tange </tmp/unittest.sql
|
|||
echo '### Test dburl with username password host port'
|
||||
sql mysql://sqlunittest:CB5A1FFFA5A@localhost:3306/sqlunittest </tmp/unittest.sql
|
||||
|
||||
echo "### Test .dburl.aliases"
|
||||
echo :sqlunittest mysql://sqlunittest:CB5A1FFFA5A@localhost:3306/sqlunittest >> ~/.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
|
||||
|
|
|
@ -10,6 +10,26 @@ EOF
|
|||
chmod 755 /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'
|
||||
cat >/tmp/shebang <<EOF
|
||||
#!/usr/local/bin/parallel -Yrk -a /tmp/123 echo
|
||||
|
|
|
@ -13,8 +13,8 @@ Yes it does
|
|||
### Test dburl with username password host port
|
||||
Test reading SQL from file works
|
||||
Yes it does
|
||||
### Test .dburl.aliases
|
||||
Test if .dburl.aliases works
|
||||
### Test .sql/aliases
|
||||
Test if .sql/aliases works
|
||||
Yes it does
|
||||
### Test --noheaders --no-headers -n
|
||||
abc 1
|
||||
|
@ -32,9 +32,9 @@ def 3
|
|||
### 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>
|
||||
### 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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue