mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-25 23:47:53 +00:00
env_parallel.fish: Compatible with fish 2.0.0.
This commit is contained in:
parent
2ba37a6d64
commit
5ed19b901c
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# This file must be sourced in fish:
|
# This file must be sourced in fish:
|
||||||
#
|
#
|
||||||
# source (which env_parallel.fish)
|
# . (which env_parallel.fish)
|
||||||
#
|
#
|
||||||
# after which 'env_parallel' works
|
# after which 'env_parallel' works
|
||||||
#
|
#
|
||||||
|
@ -88,18 +88,43 @@ function env_parallel
|
||||||
end;
|
end;
|
||||||
|
|
||||||
# Export function definitions
|
# Export function definitions
|
||||||
functions -n | perl -pe 's/,/\n/g' | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ | while read d; functions $d; end;
|
# Keep the ones from --env
|
||||||
|
# Ignore the ones from ~/.parallel/ignored_vars
|
||||||
|
# Dump each function defition
|
||||||
|
# Replace \001 with \002 because \001 is used by env_parallel
|
||||||
|
# Convert \n to \001
|
||||||
|
functions -n | perl -pe 's/,/\n/g' | \
|
||||||
|
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ | \
|
||||||
|
while read d; functions $d; end | \
|
||||||
|
perl -pe 's/\001/\002/g and not $printed++ and print STDERR
|
||||||
|
"env_parallel: Warning: ASCII value 1 in functions is not supported\n";
|
||||||
|
s/\n/\001/g';
|
||||||
# Convert scalar vars to fish \XX quoting
|
# Convert scalar vars to fish \XX quoting
|
||||||
eval (set -L | grep -E "^$_grep_REGEXP " | grep -vE "^$_ignore_UNDERSCORE " | perl -ne 'chomp;
|
# Keep the ones from --env
|
||||||
($name,$val)=split(/ /,$_,2);
|
# Ignore the ones from ~/.parallel/ignored_vars
|
||||||
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|history|status|version)$|\./ and next;
|
# Ignore read only vars
|
||||||
if($val=~/^'"'"'/) { next; }
|
# Execute 'set' of the content
|
||||||
print "set $name \"\$$name\";\n";
|
eval (set -L | \
|
||||||
')
|
grep -E "^$_grep_REGEXP " | grep -vE "^$_ignore_UNDERSCORE " | \
|
||||||
|
perl -ne 'chomp;
|
||||||
|
($name,$val)=split(/ /,$_,2);
|
||||||
|
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|
|
||||||
|
history|status|version)$|\./x and next;
|
||||||
|
if($val=~/^'"'"'/) { next; }
|
||||||
|
print "set $name \"\$$name\";\n";
|
||||||
|
')
|
||||||
# Generate commands to set scalar variables
|
# Generate commands to set scalar variables
|
||||||
|
# Keep the ones from --env
|
||||||
|
# Ignore the ones from ~/.parallel/ignored_vars
|
||||||
|
#
|
||||||
begin;
|
begin;
|
||||||
for v in (set -n | grep -E "^$_grep_REGEXP\$" | grep -vE "^$_ignore_UNDERSCORE\$");
|
for v in (set -n | \
|
||||||
|
grep -E "^$_grep_REGEXP\$" | grep -vE "^$_ignore_UNDERSCORE\$");
|
||||||
# Separate variables with the string: \000
|
# Separate variables with the string: \000
|
||||||
|
# array_name1 val1\0
|
||||||
|
# array_name1 val2\0
|
||||||
|
# array_name2 val3\0
|
||||||
|
# array_name2 val4\0
|
||||||
eval "for i in \$$v;
|
eval "for i in \$$v;
|
||||||
echo -n $v \$i;
|
echo -n $v \$i;
|
||||||
perl -e print\\\"\\\\0\\\";
|
perl -e print\\\"\\\\0\\\";
|
||||||
|
@ -108,32 +133,37 @@ function env_parallel
|
||||||
# A final line to flush the last variable in Perl
|
# A final line to flush the last variable in Perl
|
||||||
perl -e print\"\\0\";
|
perl -e print\"\\0\";
|
||||||
end | perl -0 -ne '
|
end | perl -0 -ne '
|
||||||
# Remove separator string
|
# Remove separator string \0
|
||||||
chop;
|
chop;
|
||||||
($name,$val)=split(/ /,$_,2);
|
# Split line into name and value
|
||||||
# Ignore read-only vars
|
($name,$val)=split(/ /,$_,2);
|
||||||
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|history|status|version)$/ and next;
|
# Ignore read-only vars
|
||||||
# Quote $val
|
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|
|
||||||
$val=~s/[\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\<\=\>\~\|\; \"\!\$\&\202-\377]/\\\$&/go;
|
history|status|version)$/x and next;
|
||||||
# Quote single quote
|
# Quote $val
|
||||||
$val=~s/'"'"'/\\\$&/go;
|
$val=~s/[\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\<\=\>\~
|
||||||
# Quote newline as '\n'
|
\|\; \"\!\$\&\202-\377]/\\\$&/gox;
|
||||||
$val =~ s/[\n]/\\\n/go;
|
# Quote single quote
|
||||||
# Empty => 2 single quotes = \047\047
|
$val=~s/'"'"'/\\\$&/go;
|
||||||
$val=~s/^$/\047\047/o;
|
# Quote newline as '\n'
|
||||||
if($name ne $last and $last) {
|
$val =~ s/[\n]/\\\n/go;
|
||||||
# The $name is different, so this is a new variable.
|
# Empty value => 2 single quotes = \047\047
|
||||||
# Print the last one.
|
$val=~s/^$/\047\047/o;
|
||||||
# Separate list elements by 2 spaces
|
if($name ne $last and $last) {
|
||||||
$"=" ";
|
# The $name is different, so this is a new variable.
|
||||||
print "set $last @qval;\n";
|
# Print the last one.
|
||||||
@qval=();
|
# Separate list elements by 2 spaces
|
||||||
}
|
$"=" ";
|
||||||
push @qval,$val;
|
print "set $last @qval;\n";
|
||||||
$last=$name;
|
@qval=();
|
||||||
';
|
}
|
||||||
end |perl -pe 's/\001/\\cb/g and print STDERR "env_parallel: Warning: ASCII value 1 in variables is not supported\n";
|
push @qval,$val;
|
||||||
s/\n/\001/'
|
$last=$name;
|
||||||
|
'| \
|
||||||
|
perl -pe 's/\001/\002/g and not $printed++ and print STDERR
|
||||||
|
"env_parallel: Warning: ASCII value 1 in variables is not supported\n";
|
||||||
|
s/\n/\001/g'
|
||||||
|
end;
|
||||||
)
|
)
|
||||||
perl -e 'exit grep { /^--record-env$/ } @ARGV' -- $argv; and parallel $argv;
|
perl -e 'exit grep { /^--record-env$/ } @ARGV' -- $argv; and parallel $argv;
|
||||||
set _parallel_exit_CODE $status
|
set _parallel_exit_CODE $status
|
||||||
|
|
|
@ -169,10 +169,8 @@ par_csh_underscore myecho: Command not found.
|
||||||
par_csh_underscore OK ^^^^^^^^^^^^^^^^^ if no myecho
|
par_csh_underscore OK ^^^^^^^^^^^^^^^^^ if no myecho
|
||||||
par_csh_underscore Connection to lo closed.
|
par_csh_underscore Connection to lo closed.
|
||||||
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
||||||
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
|
||||||
par_fish_funky 3 arg alias_works
|
par_fish_funky 3 arg alias_works
|
||||||
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
||||||
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
|
||||||
par_fish_funky function_works
|
par_fish_funky function_works
|
||||||
par_fish_funky myvar works
|
par_fish_funky myvar works
|
||||||
par_fish_funky myenvvar works
|
par_fish_funky myenvvar works
|
||||||
|
@ -186,10 +184,8 @@ par_fish_funky
|
||||||
par_fish_funky
|
par_fish_funky
|
||||||
par_fish_funky
|
par_fish_funky
|
||||||
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
||||||
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
|
||||||
par_fish_funky 3 arg alias_works_over_ssh
|
par_fish_funky 3 arg alias_works_over_ssh
|
||||||
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
||||||
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
|
|
||||||
par_fish_funky function_works_over_ssh
|
par_fish_funky function_works_over_ssh
|
||||||
par_fish_funky myvar works
|
par_fish_funky myvar works
|
||||||
par_fish_funky myenvvar works
|
par_fish_funky myenvvar works
|
||||||
|
@ -241,41 +237,41 @@ par_fish_underscore variables in aliases and arrays in functions work
|
||||||
par_fish_underscore variables in aliases and arrays in functions work
|
par_fish_underscore variables in aliases and arrays in functions work
|
||||||
par_fish_underscore variables in aliases and arrays in functions work
|
par_fish_underscore variables in aliases and arrays in functions work
|
||||||
par_fish_underscore variables in aliases and arrays in functions work
|
par_fish_underscore variables in aliases and arrays in functions work
|
||||||
par_fish_underscore fish: Unknown command 'not_copied_alias error=OK'
|
par_fish_underscore fish: Unknown command “not_copied_alias”
|
||||||
par_fish_underscore fish: not_copied_alias error\=OK
|
par_fish_underscore Standard input: not_copied_alias error\=OK
|
||||||
par_fish_underscore ^
|
par_fish_underscore ^
|
||||||
par_fish_underscore fish: Unknown command 'not_copied_func error=OK'
|
par_fish_underscore fish: Unknown command “not_copied_func”
|
||||||
par_fish_underscore fish: not_copied_func error\=OK
|
par_fish_underscore Standard input: not_copied_func error\=OK
|
||||||
par_fish_underscore ^
|
par_fish_underscore ^
|
||||||
par_fish_underscore error=OK
|
par_fish_underscore error=OK
|
||||||
par_fish_underscore error=OK
|
par_fish_underscore error=OK
|
||||||
par_fish_underscore aliases and arrays in functions work
|
par_fish_underscore aliases and arrays in functions work
|
||||||
par_fish_underscore aliases and arrays in functions work
|
par_fish_underscore aliases and arrays in functions work
|
||||||
par_fish_underscore aliases functions work
|
par_fish_underscore aliases functions work
|
||||||
par_fish_underscore aliases functions work
|
par_fish_underscore aliases functions work
|
||||||
par_fish_underscore fish: Unknown command 'myecho functions work'
|
par_fish_underscore fish: Unknown command “myecho”
|
||||||
par_fish_underscore fish: myecho $myarray functions $argv
|
par_fish_underscore Standard input: myecho $myarray functions $argv
|
||||||
par_fish_underscore ^
|
par_fish_underscore ^
|
||||||
par_fish_underscore in function “myfunc”
|
par_fish_underscore in function “myfunc”,
|
||||||
par_fish_underscore called on standard input
|
par_fish_underscore called on standard input,
|
||||||
par_fish_underscore with parameter list “work”
|
par_fish_underscore with parameter list “work”
|
||||||
par_fish_underscore
|
par_fish_underscore
|
||||||
par_fish_underscore OK if ^^^^^^^^^^^^^^^^^ no myecho
|
par_fish_underscore OK if ^^^^^^^^^^^^^^^^^ no myecho
|
||||||
par_fish_underscore fish: Unknown command 'myecho functions work'
|
par_fish_underscore fish: Unknown command “myecho”
|
||||||
par_fish_underscore fish: myecho $myarray functions $argv
|
par_fish_underscore Standard input: myecho $myarray functions $argv
|
||||||
par_fish_underscore ^
|
par_fish_underscore ^
|
||||||
par_fish_underscore in function “myfunc”
|
par_fish_underscore in function “myfunc”,
|
||||||
par_fish_underscore called on standard input
|
par_fish_underscore called on standard input,
|
||||||
par_fish_underscore with parameter list “work”
|
par_fish_underscore with parameter list “work”
|
||||||
par_fish_underscore
|
par_fish_underscore
|
||||||
par_fish_underscore OK if ^^^^^^^^^^^^^^^^^ no myecho
|
par_fish_underscore OK if ^^^^^^^^^^^^^^^^^ no myecho
|
||||||
par_fish_underscore fish: Unknown command 'myfunc work'
|
par_fish_underscore fish: Unknown command “myfunc”
|
||||||
par_fish_underscore fish: myfunc work
|
par_fish_underscore Standard input: myfunc work
|
||||||
par_fish_underscore ^
|
par_fish_underscore ^
|
||||||
par_fish_underscore OK if ^^^^^^^^^^^^^^^^^ no myfunc
|
par_fish_underscore OK if ^^^^^^^^^^^^^^^^^ no myfunc
|
||||||
par_fish_underscore fish: Unknown command 'myfunc work'
|
par_fish_underscore fish: Unknown command “myfunc”
|
||||||
par_fish_underscore fish: myfunc work
|
par_fish_underscore Standard input: myfunc work
|
||||||
par_fish_underscore ^
|
par_fish_underscore ^
|
||||||
par_fish_underscore OK if ^^^^^^^^^^^^^^^^^ no myfunc
|
par_fish_underscore OK if ^^^^^^^^^^^^^^^^^ no myfunc
|
||||||
par_ksh_funky
|
par_ksh_funky
|
||||||
par_ksh_funky \\\\\\\\
|
par_ksh_funky \\\\\\\\
|
||||||
|
|
Loading…
Reference in a new issue