=== modified file 'zsh-functions/confz_fileset_init' --- zsh-functions/confz_fileset_init 2016-03-15 14:20:46 +0000 +++ zsh-functions/confz_fileset_init 2016-03-15 14:00:29 +0000 @@ -7,7 +7,7 @@ zmodload -F zsh/stat b:zstat zmodload -m -F zsh/files b:zf_\* -typeset -g -A fileset_stat_cache fileset_stat_cur fileset_ftypes fileset_typenames +typeset -g -A fileset_stat_cache fileset_stat_cur fileset_ftypes typeset -g fileset_stat_cur fileset_stat_next_id fileset_stat_cur_type fileset_stat_cur_perm fileset_ftypes=( # convert hex type to a word @@ -22,15 +22,6 @@ 1 p # FIFO pipe ) -fileset_typenames=( - S "unix socket" - L "symbolic link" - f "plain file" - b "block device" - c "character device" - p "named pipe" -) - fileset_reset_cache(){ # omit unsetting used variables for now # probably no particular gain in freeing them @@ -89,18 +80,7 @@ confz_fs_type_or_missing_check() { checkvars filename flags filetype - if fileset_stat $vars[filename]; then - if [[ $fileset_stat_cur_type == $vars[filetype] ]]; then - return 0 - elif [[ $vars[flags] == *'!'* ]]; then - fail_reason="expected ${fileset_typenames[${vars[filetype]}]}, got ${fileset_typenames[$fileset_stat_cur_type]}: ${(qqq)vars[filename]}" - return 1 - else - die "$0: expected ${fileset_typenames[${vars[filetype]}]}, got ${fileset_typenames[$fileset_stat_cur_type]}: ${(qqq)vars[filename]}" - fi - else - return 0 - fi + ! fileset_stat $parent || [[ $fileset_stat_cur_type == $vars[filetype] ]] } confz_fs_type_or_missing_do() { @@ -136,7 +116,9 @@ require fs_p :filename fi - require fs_type_or_missing :filename :flags filetype=L + if [[ $vars[flags] == *'!'* ]]; then + require fs_type_or_missing :filename :flags filetype=L + fi fileset_stat $vars[filename] && \ [[ $fileset_stat_cur_type == L ]] && \ @@ -193,7 +175,9 @@ require fs_p :filename fi - require fs_type_or_missing :filename :flags filetype=f + if [[ $vars[flags] == *'!'* ]]; then + require fs_type_or_missing :filename :flags filetype=f + fi fileset_stat $vars[filename] && [[ $fileset_stat_cur_type == f ]] } @@ -207,7 +191,9 @@ confz_fs_d_check() { checkvars filename flags - require fs_type_or_missing :filename :flags filetype=d + if [[ $vars[flags] == *'!'* ]]; then + require fs_type_or_missing :filename :flags filetype=d + fi if [[ $vars[flags] == *p* ]]; then do_command=( fileset_resetcmd mkdir -p $vars[filename] )