rpmconf-matt: Switch from dnf-download-signed (which I forgot to
[utils/utils.git] / ftc
1 #!/bin/bash
2 # ftc <file>: file tree create
3 set -e
4
5 function ftc_sub {
6 if [ -h "$1" ]; then
7         ltarget="$(readlink -- "$1" && echo 'x')"
8         ltarget="${ltarget%
9 x}"
10         echo "l ${#ltarget} $ltarget"
11 elif [ -f "$1" ]; then
12         if [ -x "$1" ]; then
13                 stat --format=$'x %s' -- "$1"
14         else
15                 stat --format=$'f %s' -- "$1"
16         fi
17         cat -- "$1"
18         echo
19 elif [ -d "$1" ]; then
20         (
21         echo "{"
22         cd -- "$1"
23         unset GLOBIGNORE
24         shopt -s nullglob
25         shopt -s dotglob
26         for entry in *; do
27                 echo -n "+ ${#entry} $entry "
28                 ftc_sub "$entry"
29         done
30         echo "}"
31         )
32 else
33         echo "File of unknown type!" 1>&2
34 fi
35 }
36
37 ftc_sub "$1"