doc: git doesn't use git-foo invocations.
[guilt.git] / os.Darwin
blob3f231214476eff558c1858331576a583e711b0fa
1 # usage: touch_date <unix ts> <file>
2 touch_date()
4         touch -t `date -r $1 +%Y%m%d%H%M.%S` "$2"
7 # usage: last_modified <file>
8 last_modified()
10         stat -f "%m" "$1"
13 # usage: format_last_modified <file>
14 format_last_modified()
16         stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S %z" "$1"
19 # usage: head_n [count]
20 head_n()
22         if [ "$1" -gt 0 ]; then
23                 head -n "$1"
24         fi
27 # usage: sha1 [file]
28 sha1()
30         if [ $# = 1 ]
31         then
32                 openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
33         else
34                 openssl dgst -sha1 | sed 's,\(.*= \)*\(.*\),\2  -,'
35         fi
38 # usage: cp_a <src> <dst>
39 cp_a()
41         cp -pR "$1" "$2"
44 # usage: _tac
45 _tac()
47         sed -e '1!G;h;$!d'
50 _seq()
52         (
53                 if [ $# -eq 1 ]
54                 then
55                         /usr/bin/jot $1
56                 elif [ $# -eq 2 ]
57                 then
58                         n1=$((${2} - ${1} + 1))
59                         n2=$1
60                         /usr/bin/jot $n1 $n2
61                 elif [ $# -eq 3 ]
62                 then
63                         num1=$1
64                         incr=$2
65                         num2=$3
66                         /usr/bin/awk -v n1=$num1 -v n2=$num2 -v add=$incr 'BEGIN{ for(i=n1; i<=n2; i+=add) print i;}' | /usr/bin/sed -E '/e/s/^.+e.+$/0/'
67                 fi
68         )
69         return 0