[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
issue with [[ -v A[\$k] ]]
From: |
alex xmb ratchev |
Subject: |
issue with [[ -v A[\$k] ]] |
Date: |
Sun, 21 May 2023 22:35:03 +0200 |
i made some simple dup file by checksum remover
however the [[ -v assoc[\$var] didnt work
maybe due to your announced changes
i dunno
i cant track or much understand that english
to pre explain my code
a is arr with files ( non dirs ) by find "$@"
h is the same file mapping but in hashes
first a is first h .. and so on
if #a != #h exit with err ( i fast exec i dont care )
then interate from keys h ( or a , same .. )
and in there i like used to , did [[ -v assoc[\$key] ]]
but to my surprise it didnt work
.. i have declare -n for short
but after z=$key to plain var , it still didnt work
after removing the backslash before $key it worked
i figured i d try ${key@Q} as key but it also didnt work
so ..
[[ -v assoc[$key] ]] .. without \ works
rest not anymore ?
whats the non eval version of assoc [[ -v
is it already
for me to say , plz correct me if its not right
about the non-abuse-protection
eg good code ..
a = index arr
h = index arr
k = for key in a or h
declare -n two things .. sorry foun touchscreen is pain to write
and the [[ -v assoc key , is ( in not code modfied , eg no hackers ) , is
simply the blake2 sum ( b2sum is in coreutils / 2022 ).
no eval or stuff .. or ?
q : what bash code to write to have random input as secure keys ?
/xmb
~ $ cat dupaway
#!/bin/bash
unset -v IFS a h d n f y1 y2 z ; IFS=$' \t\n'
(( ! $# )) &&
exec printf 'err , find entry paths as args\n'
mapfile -d '' a < <( find "$@" ! -type d -print0 )
mapfile -d '' h < <(
b2sum -bz "${a[@]}" |
awk -vRS=\\0 -vORS=\\0 ' { print $1 } '
)
##declare -p h
##exit
! (( ( y1 = ${#a[@]} ) == ( y2 = ${#h[@]} ) )) &&
exec printf 'err , files count != checksum count , %s\n' "$y1 vs $y2"
declare -A d
for k in ${!h[@]} ; do
declare -n n=h\[k] f=a\[k]
##z=$n
##declare -p z
##printf 'debug %s\n' "$n -- $f"
if [[ -v d[$n] ]] ; then
printf 'rm %q\n' "$f"
: \
rm "$f"
else
d[$n]=
fi
done
dupaway
Description: Binary data
- issue with [[ -v A[\$k] ]],
alex xmb ratchev <=