web-logs/Makefile: Use only the previous day's logs to avoid overlap.
[utils/utils.git] / ftx
CommitLineData
273c3903
MM
1#!/bin/bash
2# ftx <file>: file tree extract
3set -e
4
5function skip {
6 read -n $1 trash
7}
8
9function ftx_sub {
10 if [ -h "$1" ] || [ -a "$1" ]; then
11 echo "File already exists!" 1>&2
12 return 1
13 fi
14 read -n 1 type
15 case $type in
16 f|x)
17 skip 1 # space
18 read length
19 head -c "$length" >"$1"
20 if [ $type == x ]; then
6ac3cd7b 21 chexec + "$1"
273c3903
MM
22 fi
23 skip 1 # newline
24 ;;
25 {)
26 skip 1 # newline
27 mkdir -- "$1"
28 (
29 cd -- "$1"
30 while read -n 1 what && [ $what == '+' ]; do
31 skip 1 # space
32 read -d ' ' length
33 read -d '' -n $length name
34 skip 1 # space
35 ftx_sub "$name"
36 done
37 skip 1 # newline
38 )
39 ;;
40 l)
41 skip 1 # space
42 read -d ' ' length
43 read -d '' -n $length target
44 skip 1 # newline
45 ln -s -- "$target" "$1"
46 ;;
47 esac
48}
49
50ftx_sub "$1"