Mercurial > ec-dotfiles
comparison bin/index2 @ 129:f18a27a0e8fc
Merge branch.
| author | Edho Arief <edho@myconan.net> |
|---|---|
| date | Sat, 29 Oct 2011 11:40:35 +0700 |
| parents | 5bafb912837e |
| children |
comparison
equal
deleted
inserted
replaced
| 121:0c3b473b9af7 | 129:f18a27a0e8fc |
|---|---|
| 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 "$@" |
