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
}
peach [f]{
var f = $f
if (eq $f[-1] /) {
f = $f[..-1]
var ff = $f
if (eq $ff[-1] /) {
f = $ff[..-1]
}
$cmd archive $f'.tar.'$format $f
echo "'"$f"'" archivé
$cmd archive $ff'.tar.'$format $ff
echo "'"$ff"'" archivé
} $argv
}
edit:add-var desarchiver~ [@argv]{
peach [f]{
var f = $f
$cmd unarchive $f
echo "'"$f"'" désarchivé
var ff = $f
$cmd unarchive $ff
echo "'"$ff"'" désarchivé
} $argv
}
edit:add-var listarchiver~ [@argv]{
peach [f]{
local f = $f
$cmd ls $f
var ff = $f
$cmd ls $ff
} $argv
}

View File

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

View File

@ -35,10 +35,8 @@ fn -search [&sort=$false &type=exact @motive]{
result = (put * | map:to-set)
} else {
peach [m]{
var m = $m
try {
$f $m | peach [e]{
var e = $e
result[$e] = $nil
}
} 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]{
result = [&]
-search &type=$type $motive | peach [f]{
var f = $f
if (list:contains [e]{ str:has-suffix $f .$e } $extensions) {
result[$f] = $nil
}

View File

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