comparison bin/index2 @ 138:f963d52c031a

Merge.
author Edho Arief <edho@myconan.net>
date Wed, 02 Nov 2011 22:12:16 +0700
parents 5bafb912837e
children
comparison
equal deleted inserted replaced
137:983beb13c736 138:f963d52c031a
1 #!/bin/sh
2
3 # Index version 2! Much better than first one. Hopefully.
4
5 # Execute safely.
6 safe_path()
7 {
8 __start=$(printf "%s" | cut -c 1)
9 __path=
10 case "${__start}" in
11 .|/) __path="$*";;
12 *) __path="./$*";;
13 esac
14 printf "%s" "${__path}"
15 }
16
17 get_basename() { basename "$(safe_path "$*")"; }
18 get_basename_pipe() { sed -e 's#.*/\([/]*\)$#\1#'; }
19
20 filename_hash()
21 {
22 printf "%s" "$(get_basename "$*")"
23 }
24 generate_table_of_files()
25 {
26 filetable_generator "$@"
27 }
28 filetable_generator()
29 {
30 # Uses perl for speed.
31 perl -e 'use File::Find;
32 use Digest::SHA1 qw(sha1_hex);
33 use_warnings;
34 use_strict;
35 sub printer { printf("%s\n", sha1_hex($_)) if(-e && -f && !-l); }
36 find(\&printer, @ARGV);' "$@"
37 }
38 _srcdir=.
39 generate_table_of_files "$@"