1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 04:39:03 -08:00

allow baknow to take multiple file arguments

This commit is contained in:
Connor Olding 2021-08-23 04:52:23 -07:00
parent dce4a25f12
commit a0d1feaf29

View file

@ -1,9 +1,10 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# YES_ZSH # YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
baknow() { ### @- baknow() { ### @- backup files by appending their timestamps given by [`now`.](#now)
### backup a single file by appending its timestamp given by [`now`.](#now)
###
### ``` ### ```
### $ touch -d '2001-12-25 16:30:00' butts ### $ touch -d '2001-12-25 16:30:00' butts
### $ baknow butts ### $ baknow butts
@ -14,9 +15,14 @@ baknow() { ### @-
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts ### -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 ### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.2001-12-26_01800000.bak
### ``` ### ```
### argc -ge 1 "$0" "$@" || return
### **TODO:** support multiple files at once. local ret=0
cp -ip "${1:?missing file argument}" "$1.$(now "$1").bak" 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 "$@" [ -n "${preload+-}" ] || baknow "$@"