ref: e61f14729a8087126515a81c94a3d95f7aa79ac8
parent: ab0dac73aece10d6e2eae9aaa3aa20268d1d2e89
author: saeed <saeed@cloud9p.org>
date: Mon Aug 25 18:35:36 IDT 2025
pasted: lots of fixes, thanks jm@cloud9p.org
--- a/plan9/pasted
+++ b/plan9/pasted
@@ -1,20 +1,36 @@
#!/bin/rc
# wm/pasted path
# a simple pastebin, use with aux/listen
-if(! ~ $#* 1) {
- echo 'usage: wm/pasted user' >[1=2]
- exit usage
-}
-# not to override files
fn genrand {
- dir = $1
rand = `{dd -quiet 1 -if /dev/random -bs 1 -count 2 | xd -1 | awk '{$1=""; print $0}' | tr -d ' '}
- if(test -e $dir/$rand){
+ # not to override non-empty files
+ if(test -s $dir/$rand){
genrand
}
}
+if(~ $#* 0) {
+ echo 'usage: wm/pasted dir [prefix]' >[1=2]
+ exit usage
+}
+if not
+ dir = $1
+
+if(~ $#* 2)
+ prefix = $2
+if not
+ prefix = ''
+
+
genrand $1
-echo $rand
-read -m -c `{echo '1024 * 1024 * 10'| bc} > $dir/$rand
+echo $prefix^$rand
+touch $dir/$rand
+chmod +at $dir/$rand
+read -m -c `{echo '1024 * 1024 * 8'| bc} > $dir/$rand
+
+# remove some of empty entries
+if(! test -s $dir/$rand)
+ rm $dir/$rand
+if not
+ chmod go-w $dir/$rand
--
⑨