ref: 171d78f72e972c8671e39b064e9d1072f3130560
parent: bfbee0e43fd147a6cfa1289e37c06f271adb0af4
author: kvik <kvik@a-b.xyz>
date: Sat Apr 18 19:02:29 EDT 2020
bag: now comes with the tag; ramfs /tmp fix Mounting ramfs on /tmp is problematic when a program wants to use files from what was previously /tmp.
--- a/bin/bag
+++ b/bin/bag
@@ -4,13 +4,22 @@
usage='bag [-f] file ...'
fn bag {
- name = $1
- h = `{sha1sum $name | sed 's/(..)(....).*/\1 \2/'}
+ file = $1
+ h = `{sha1sum $file | sed 's/(..)(....).*/\1 \2 &/'}
b = $h(1)
f = $b^/^$h(2)
+ h = $h(3)
if(~ $force yes || ! test -e $bag/$f){
mkdir -p $bag/$b
- fcp $name $bag/$f
+ >>$bag/$f.tag {
+ echo 'hash:' $h
+ echo 'file:' $file
+ echo 'date:' `{date -um}
+ echo 'tags:' $tags
+ echo 'note:' $note
+ }
+ touch $bag/$f
+ fcp $file $bag/$f
}
if not
>[1=2] echo already bagged
@@ -22,10 +31,18 @@
if(~ $#bagurl 0)
bagurl = http://a-b.xyz
force = no
+tags = ()
+note = ()
while(~ $1 -* && ! ~ $1 --){
switch($1){
case -f
force = yes
+ case -t
+ shift
+ tags = ($tags $1)
+ case -m
+ shift
+ note = $1
case *
usage
}
@@ -33,12 +50,14 @@
}
if(~ $1 --)
shift
+
+9fs bag
+ramfs -u -m /mnt/ram
+
files = ($*)
if(~ $#files 0){
- ramfs -u
- cat /fd/0 >/tmp/bag.tmp
- files = (/tmp/bag.tmp)
+ cat /fd/0 >/mnt/ram/stdin
+ files = (/mnt/ram/stdin)
}
-9fs bag
for(f in $files)
bag $f