mirror of
https://github.com/notwa/rc
synced 2024-11-05 02:59:03 -08:00
28 lines
746 B
Bash
Executable file
28 lines
746 B
Bash
Executable file
#!/usr/bin/env sh
|
|
# YES_ZSH
|
|
# YES_BASH
|
|
# YES_DASH
|
|
# YES_ASH
|
|
|
|
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
|
|
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 "$@"
|