-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaknow
More file actions
executable file
·25 lines (23 loc) · 777 Bytes
/
Copy pathbaknow
File metadata and controls
executable file
·25 lines (23 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env sh
# compat: -ash +bash +dash -hush -ksh +mksh -oksh +osh +posh +yash +zsh
baknow() { ### @- backup files by appending their timestamps given by [`now`.](#now)
### ```
### $ touch -d '2001-12-25 16:30:00' butts
### $ baknow butts
### $ baknow butts
### cp: overwrite 'butts.2001-12-26_01800000.bak'? n
### $ ls -l
### total 0
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.2001-12-26_01800000.bak
### ```
argc $# -ge 1 "$0" || return
local ret=0 f=
for f; do
cp -ip "$f" "$f.$(now "$f").bak" || ret=1
done
return $ret
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} argc now
[ -n "${preload+-}" ] || baknow "$@"