mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 14:07:55 +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
|
||||||
|
# Ignore the ones from ~/.parallel/ignored_vars
|
||||||
|
# Ignore read only vars
|
||||||
|
# Execute 'set' of the content
|
||||||
|
eval (set -L | \
|
||||||
|
grep -E "^$_grep_REGEXP " | grep -vE "^$_ignore_UNDERSCORE " | \
|
||||||
|
perl -ne 'chomp;
|
||||||
($name,$val)=split(/ /,$_,2);
|
($name,$val)=split(/ /,$_,2);
|
||||||
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|history|status|version)$|\./ and next;
|
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|
|
||||||
|
history|status|version)$|\./x and next;
|
||||||
if($val=~/^'"'"'/) { next; }
|
if($val=~/^'"'"'/) { next; }
|
||||||
print "set $name \"\$$name\";\n";
|
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,18 +133,21 @@ 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;
|
||||||
|
# Split line into name and value
|
||||||
($name,$val)=split(/ /,$_,2);
|
($name,$val)=split(/ /,$_,2);
|
||||||
# Ignore read-only vars
|
# Ignore read-only vars
|
||||||
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|history|status|version)$/ and next;
|
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|
|
||||||
|
history|status|version)$/x and next;
|
||||||
# Quote $val
|
# Quote $val
|
||||||
$val=~s/[\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\<\=\>\~\|\; \"\!\$\&\202-\377]/\\\$&/go;
|
$val=~s/[\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\<\=\>\~
|
||||||
|
\|\; \"\!\$\&\202-\377]/\\\$&/gox;
|
||||||
# Quote single quote
|
# Quote single quote
|
||||||
$val=~s/'"'"'/\\\$&/go;
|
$val=~s/'"'"'/\\\$&/go;
|
||||||
# Quote newline as '\n'
|
# Quote newline as '\n'
|
||||||
$val =~ s/[\n]/\\\n/go;
|
$val =~ s/[\n]/\\\n/go;
|
||||||
# Empty => 2 single quotes = \047\047
|
# Empty value => 2 single quotes = \047\047
|
||||||
$val=~s/^$/\047\047/o;
|
$val=~s/^$/\047\047/o;
|
||||||
if($name ne $last and $last) {
|
if($name ne $last and $last) {
|
||||||
# The $name is different, so this is a new variable.
|
# The $name is different, so this is a new variable.
|
||||||
|
@ -131,9 +159,11 @@ function env_parallel
|
||||||
}
|
}
|
||||||
push @qval,$val;
|
push @qval,$val;
|
||||||
$last=$name;
|
$last=$name;
|
||||||
';
|
'| \
|
||||||
end |perl -pe 's/\001/\\cb/g and print STDERR "env_parallel: Warning: ASCII value 1 in variables is not supported\n";
|
perl -pe 's/\001/\002/g and not $printed++ and print STDERR
|
||||||
s/\n/\001/'
|
"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,11 +237,11 @@ 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
|
||||||
|
@ -253,28 +249,28 @@ 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
|
||||||
|
|
Loading…
Reference in a new issue