Mercurial > ec-dotfiles
comparison bin/index2 @ 124:5bafb912837e
Massive addition of old scripts collection.
author | Edho Prima Arief <edho@myconan.net> |
---|---|
date | Wed, 26 Oct 2011 15:22:00 +0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
123:173833e4ba35 | 124:5bafb912837e |
---|---|
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 "$@" |