=== removed directory 'bin' === removed file 'bin/fslist' --- bin/fslist 2013-09-26 18:03:45 +0000 +++ bin/fslist 1970-01-01 00:00:00 +0000 @@ -1,92 +0,0 @@ -#!/bin/zsh -# there is no posix stat(1) and the implementations are riddled with locale-speciffic stuff -# better use sane version from zsh - -setopt extendedglob globdots -zmodload zsh/stat - -typeset -A ftypes hardlinks -ftypes=( # convert hex type to mnemonic character - c S # socket - a l # symbolic link - 8 f # regular file - 6 B # block device - 4 d # directory - 2 C # character device - 1 p # FIFO -) - -delim='' - -statement() { - # start on new line for multiline statements - more readable - if [[ -n delim && $1 == *$'\n'* ]]; then - delim=$'\n' - fi - printf '%s%s' $delim ${1//$'\n'/$'\n\t'} - delim=${2:-$'\t'} -} - -statement_end() { - printf '\n' - delim='' -} - -for arg in "${@:-$PWD}"; do - for fname in $arg:a/**/*; do - zstat -LH s $fname || continue - ftype=$(( [##16] $s[mode] >> 12 )) - fmode=$(( [##8] $s[mode] & 8#7777 )) - t=$ftypes[$ftype] - - if [[ $fname == *$'\t'* || $fname == *$'\n'* ]]; then - statement $'P\t'$fname $'\t' - else - statement $fname - fi - - if [[ $t != d && $s[nlink] -gt 1 ]]; then - id=$s[device]:$s[inode] - if (($+hardlinks[$id])); then - statement $'H\t'$hardlinks[$id] $'\n' - continue - else - hardlinks[$id]=$fname - fi - fi - - if [[ $t == [BC] ]]; then - statement $t$(( $s[rdev] >> 8 )):$(( $s[rdev] & 255 )) - elif [[ $t == l ]]; then - statement $'l\t'$s[link] $'\t' - elif [[ $t == f ]]; then - IFS= read -r -d '' content <$fname - flags='' - if [[ $content == *$'\n' ]]; then - content=${content%$'\n'} - else - flags+=N - fi - statement c$flags$'\t'$content $'\n' - fi - statement o$s[uid]:$s[gid] - statement m$fmode - statement_end - done -done - -# while getopts omcaOMC o -# do case "$o" in -# ([?]) -# print >&2 "Usage: $(basename "$0") [-omcaOMC] [dir [...]]" -# exit 1;; -# esac -# done - -# find "${@:-$PWD}" -exec stat -c '%F %U:%G %a %h:%i:%d %t:%T %n' '{}' + | awk ' -# BEGIN { -# FS="\t" -# } - -# /\t/ -# ' === renamed file 'bin/fileset.awk' => 'fileset.awk' --- bin/fileset.awk 2013-09-26 18:03:45 +0000 +++ fileset.awk 2013-09-25 19:46:16 +0000 @@ -7,13 +7,13 @@ # header print "#!/bin/sh" print "export fname dirname" - print "die() { printf '%s\n' \"$*\"; exit 1 }" + print "die() { printf '%s' \"$*\"; exit 1 }" } function escaped(str) { gsub(/\\/, "\\\\", str) -# gsub(/\n/, "\\n", str) - gsub(/([\\"`$])/, "\\\\&", str) + gsub(/\n/, "\\n", str) + gsub(/\([\\"`$]\)/, "\\\1", str) return str } @@ -113,31 +113,6 @@ continue } - if(cchar == "u") { - print_i("umask "crest) - continue - } - - # remove - if(cchar == "r") { - print_b("if test -e "fname"; then") - if(crest ~ /r/) { - if(crest ~ /f/) { - print_d("rm -rf "fname) - } else { - print_d("rm -r "fname) - } - } else { - } - if(crest ~ /f/) { - print_d("rm -f "fname) - } else { - print_d("rm "fname) - } - print_e("fi") - continue - } - if(cchar == "f") { cmd_mknod("test -f "fname, "file", "touch fname") continue @@ -198,10 +173,14 @@ cmd_mknod("test -f "fname, "file") # unless disabled with the N flag, append newline at the end of # last line, if not already present - printf_fmt = (crest !~ /N/ && statement !~ /\n$/) ? \ - "%s\n" : "%s" - printf_redir = (crest ~ /a/ ? ">>" : ">") fname - print_d("printf "printf_redir" '"printf_fmt"' "quoted(statement)) + if(crest !~ /N/ && statement !~ /\n$/) { + statement = statement "\n" + } + if(crest ~ /a/) { + print_d("printf >>"fname" '%s' "quoted(statement)) + } else { + print_d("printf >"fname" '%s' "quoted(statement)) + } statement = "" continue }