fileset

git mirror of https://ccx.te2000.cz/bzr/fileset
git clone https://ccx.te2000.cz/git/fileset
Log | Files | Refs | README

commit c1f91b34f2a7f1740649162828e0b3401a2e12d6
parent b628b3fd92d81d6fedf0a43bd377379998546d22
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Tue, 15 Mar 2016 14:50:30 +0100

change fileset_stat_cur to be associative array instead of parameter name
Diffstat:
Mzsh-functions/confz_fileset_init | 24+++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/zsh-functions/confz_fileset_init b/zsh-functions/confz_fileset_init @@ -19,20 +19,20 @@ fileset_ftypes=( # convert hex type to a word 1 p # FIFO pipe ) -typeset -g -A fileset_stat_cache +typeset -g -A fileset_stat_cache fileset_stat_cur typeset -g fileset_stat_cur fileset_stat_next_id fileset_stat_cur_type fileset_stat_cur_perm fileset_reset_cache(){ # omit unsetting used variables for now # probably no particular gain in freeing them - fileset_stat=() - fileset_stat_cur= + fileset_stat_cache=() + fileset_stat_cur=() fileset_stat_next_id=1 } fileset_reset_cache # runs zstat on $1 if not already in cache -# the result is available as ${(P)fileset_stat_cur} +# the result is available as $fileset_stat_cur associative array fileset_stat() { local id ret ftype fperm id=${fileset_stat_cache[$1]:-missing} @@ -56,10 +56,12 @@ fileset_stat() { } fileset_stat_set_cur(){ - fileset_stat_cur=fileset_stat_$1 - ftype=$[ [##16] ${${(P)fileset_stat_cur}[mode]} >> 12 ] + local param + param=fileset_stat_$1 + fileset_stat_cur=( "${(@kvP)param}" ) + ftype=$[ [##16] $fileset_stat_cur[mode] >> 12 ] fileset_stat_cur_type=$fileset_ftypes[$ftype] - fileset_stat_cur_perm=$[ [##8] ${${(P)fileset_stat_cur}[mode]} & 4095 ] + fileset_stat_cur_perm=$[ [##8] $fileset_stat_cur[mode] & 4095 ] } fileset_resetcmd() { @@ -120,7 +122,7 @@ confz_fs_l_check() { fileset_stat $vars[filename] && \ [[ $fileset_stat_cur_type == L ]] && \ - [[ ${${(P)fileset_stat_cur}[link]} == $vars[destination] ]] + [[ $fileset_stat_cur[link] == $vars[destination] ]] } confz_fs_l_do() { @@ -156,10 +158,10 @@ confz_fs_o_check() { die "fs_o: could not access file ${(qqq)vars[filename]}" if [[ $vars[owner] =~ '^[0-7]+:[0-7]+$' ]]; then - (( ${${(P)fileset_stat_cur}[uid]} == ${${vars[owner]}%:*} && \ - ${${(P)fileset_stat_cur}[gid]} == ${${vars[owner]}#*:} )) + (( $fileset_stat_cur[uid] == ${${vars[owner]}%:*} && \ + $fileset_stat_cur[gid] == ${${vars[owner]}#*:} )) elif [[ $vars[owner] =~ '^[0-7]+$' ]]; then - (( ${${(P)fileset_stat_cur}[uid]} == ${${vars[owner]}%:*} )) + (( $fileset_stat_cur[uid] == ${${vars[owner]}%:*} )) else die "fs_o does not support non-numeric user/group: ${(qqq)vars[owner]}" fi