shithub: mq

Download patch

ref: e17ea9d6bc50ccf3291647bf2af303dc254b327f
parent: 4d09034e2a37db351b93ca0b1e65bce67f49d2e3
author: kvik <kvik@a-b.xyz>
date: Sun Dec 13 11:26:26 EST 2020

pin: add the -s option

--- a/man/1/pin
+++ b/man/1/pin
@@ -9,6 +9,9 @@
 .B -m
 .I mtpt
 ] [
+.B -s
+.I mq
+] [
 .I id
 ] [
 .I command
@@ -48,7 +51,7 @@
 expects an
 .IR mq (4)
 instance mounted on
-.BR /n/pin
+.B /n/pin
 or
 .I mtpt
 in case the
@@ -57,8 +60,12 @@
 If no such mount is present,
 .I pin
 mounts the channel posted on
-.BR /srv/pin-$user ,
-creating it if needed.
+.B /srv/pin-$user
+or
+.B /srv/$mq
+in case the
+.B -s
+option is given, creating it if needed.
 .SH EXAMPLES
 .PP
 Pin an
--- a/rc/pin
+++ b/rc/pin
@@ -45,11 +45,14 @@
 		wait $apid
 }
 
-flagfmt = 'a:attach, c:create, w:write, m:mtpt mtpt'
+flagfmt = 'a:attach, c:create, w:write, m:mtpt mtpt, s:srv srv'
 args = 'id [command]'
 eval `''{aux/getflags $*} || exec aux/usage
 
-srv = pin-$user
+if(~ $#srv 0)
+	srv = pin-$user
+if(~ $#mtpt 0)
+	mtpt = /n/pin
 id = $1
 if(~ $#id 0)
 	exec aux/usage
@@ -58,8 +61,6 @@
 	nocmd = 1
 	cmd = (rc -i)
 }
-if(~ $#mtpt 0)
-	mtpt = /n/pin
 
 # Run and mount if not already mounted
 if(! ~ `{walk -n0 -eq $mtpt} a000000000000000.0.80){