Correction problème des peach

This commit is contained in:
Benjamin VAUDOUR 2021-08-28 10:58:07 +02:00
parent ec1c063802
commit f8a35a9da3
4 changed files with 23 additions and 28 deletions

View File

@ -28,26 +28,26 @@ edit:add-var archiver~ [@argv]{
$help $help
} }
peach [f]{ peach [f]{
var f = $f var ff = $f
if (eq $f[-1] /) { if (eq $ff[-1] /) {
f = $f[..-1] f = $ff[..-1]
} }
$cmd archive $f'.tar.'$format $f $cmd archive $ff'.tar.'$format $ff
echo "'"$f"'" archivé echo "'"$ff"'" archivé
} $argv } $argv
} }
edit:add-var desarchiver~ [@argv]{ edit:add-var desarchiver~ [@argv]{
peach [f]{ peach [f]{
var f = $f var ff = $f
$cmd unarchive $f $cmd unarchive $ff
echo "'"$f"'" désarchivé echo "'"$ff"'" désarchivé
} $argv } $argv
} }
edit:add-var listarchiver~ [@argv]{ edit:add-var listarchiver~ [@argv]{
peach [f]{ peach [f]{
local f = $f var ff = $f
$cmd ls $f $cmd ls $ff
} $argv } $argv
} }

View File

@ -31,9 +31,9 @@ edit:add-var ipof~ [@argv]{
var value = (str:trim-space $l[$idx".."]) var value = (str:trim-space $l[$idx".."])
if (or (str:has-prefix $l 'IPv4 addresses') (str:has-prefix $l 'IPv6 addresses')) { if (or (str:has-prefix $l 'IPv4 addresses') (str:has-prefix $l 'IPv6 addresses')) {
str:split ', ' $value | peach [e]{ str:split ', ' $value | peach [e]{
var e = $e var ee = $e
if (ip:is-ip $e) { if (ip:is-ip $ee) {
result[ips][$e] = $nil result[ips][$ee] = $nil
} }
} }
} elif (str:has-prefix $l 'TXT records') { } elif (str:has-prefix $l 'TXT records') {
@ -49,28 +49,27 @@ edit:add-var ipof~ [@argv]{
var hosts = [&] var hosts = [&]
cat /etc/hosts | peach [l]{ cat /etc/hosts | peach [l]{
var l = $l var ll = (str:trim-space $l)
l = (str:trim-space $l) if (and (not-eq $ll '') (not-eq $ll[0] '#')) {
if (and (not-eq $l '') (not-eq $l[0] '#')) { put $ll
put $l
} }
} | eawk [_ ip @domains]{ } | eawk [_ ip @domains]{
peach [d]{ peach [d]{
var d = $d var dd = $d
if (has-key $hosts $d) { if (has-key $hosts $dd) {
hosts[$d][$ip] = $nil hosts[$dd][$ip] = $nil
} else { } else {
hosts[$d] = [&$ip=$nil] hosts[$dd] = [&$ip=$nil]
} }
} $domains } $domains
} }
var remote = [&] var remote = [&]
peach [d]{ peach [d]{
var d = $d var dd = $d
var solve = (dnssolve $d) var solve = (dnssolve $dd)
if (> (keys $solve[ips] | count) 0) { if (> (keys $solve[ips] | count) 0) {
remote[$d] = $solve remote[$dd] = $solve
} }
} $argv } $argv

View File

@ -35,10 +35,8 @@ fn -search [&sort=$false &type=exact @motive]{
result = (put * | map:to-set) result = (put * | map:to-set)
} else { } else {
peach [m]{ peach [m]{
var m = $m
try { try {
$f $m | peach [e]{ $f $m | peach [e]{
var e = $e
result[$e] = $nil result[$e] = $nil
} }
} except e { } } except e { }
@ -52,7 +50,6 @@ fn match-files [&sort=$false &type=prefix @motive]{ -search &sort=$sort &type=$t
fn match-extensions [&sort=$false &type=deep-prefix motive @extensions]{ fn match-extensions [&sort=$false &type=deep-prefix motive @extensions]{
result = [&] result = [&]
-search &type=$type $motive | peach [f]{ -search &type=$type $motive | peach [f]{
var f = $f
if (list:contains [e]{ str:has-suffix $f .$e } $extensions) { if (list:contains [e]{ str:has-suffix $f .$e } $extensions) {
result[$f] = $nil result[$f] = $nil
} }

View File

@ -263,7 +263,6 @@ fn remove-duplicate [@argv]{
fn premove-duplicate [@argv]{ fn premove-duplicate [@argv]{
var done = [&] var done = [&]
peach [v]{ peach [v]{
var v = $v
done[$v] = $nil done[$v] = $nil
} (-p $@argv) } (-p $@argv)
keys $done keys $done