ref: 932aa079d1f8a98ba1d50e7bb4b3ea876053125c
parent: 832e8448b3bd0aec97693691c7bd190bf8dcd504
author: Michael Misch <michaelmisch1985@gmail.com>
date: Wed Aug 28 22:10:17 PDT 2024
Drop a few more scripts in
--- a/README.md
+++ b/README.md
@@ -15,8 +15,11 @@
# assuming project has a docs/ dir with project-specific documents
bind /path/to/project /mnt/work
- bind -a /path/to/additional/related/resources /mnt/work/docs
+ bind /path/to/additional/related/resources /mnt/work/docs
bind -a /path/to/other/resources /mnt/work/docs
+
+ # You can also just include other namespace files
+ . /usr/glenda/lib/doc.namespace.resource
Now in any window related to your project, you can `mount /srv/work /mnt/work`
- Useful for `acme /mnt/work`
--- /dev/null
+++ b/add
@@ -1,0 +1,80 @@
+#!/bin/rc -e
+rfork ne
+
+# Remove commentary lines.
+# Remove leading and trailing empty lines.
+# Combine consecutive empty lines between paragraphs.
+# Remove trailing spaces from lines.
+# Ensure there's trailing newline.
+fn cleanmsg{
+ awk '
+ /^[ ]*#/ {next}
+ /^[ ]*$/ {empty = 1; next}
+
+ wet && empty {printf "\n"}
+ {wet = 1; empty = 0}
+ {sub(/[ ]+$/, ""); print $0}
+ '
+}
+
+fn editmsg{
+ if(! test -s $msgfile.tmp){
+ >$msgfile.tmp {
+ echo -n '# tag:' $tag
+ if(! ~ $#before 0)
+ echo -n ' before:' $before
+ if(! ~ $#after 0)
+ echo -n ' after:' $after
+ echo ''
+ echo $data
+ }
+ edit=1
+ }
+ if(~ $#editor 0)
+ editor=hold
+ $editor $msgfile.tmp
+
+ cleanmsg < $msgfile.tmp > $msgfile
+ if(! test -s $msgfile){
+ echo 'empty task message' >[1=2]
+ exit 'task'
+ }
+}
+
+fn gettag{
+ files=`{ls .pro/todo/}
+ if(! ~ $#change 0)
+ tag=$change
+ if not
+ tag=$#files
+}
+
+fn final{
+ cp $msgfile .pro/todo/$tag
+}
+
+fn sigexit{
+ if(! ~ $#msgfile 0)
+ rm -f $msgfile $msgfile.tmp
+}
+
+flagfmt='c:change change, a:after after, b:before before, e:edit'; args='[msg ...]'
+eval `''{aux/getflags $*} || exec aux/usage
+
+msgfile=/tmp/pro-msg.$pid
+if(! ~ $#* 0){
+ data=`{echo $*}
+if(! ~ $#change 0 )
+ if(test -s .pro/todo/$change){
+ cat .pro/todo/$change > $msgfile.tmp
+ if(! ~ $#data 0)
+ echo $data >> $msgfile.tmp
+ }
+
+@{
+ flag e +
+ gettag
+ editmsg
+ final
+} || echo 'could not add task:' $status >[1=2]
+exit ''
--- a/conf.c
+++ b/conf.c
@@ -103,31 +103,32 @@
while((ln = Brdstr(f, '\n', 1)) != nil){
p = strip(ln);
if(strncmp(p, "name", 4) == 0){
-print("Starting sfile\n");
+print("Into Sfile\n");
p = strip(p + 4);
if(*p == '='){
p = strip(p + 1);
conf->sfile = strcat("/srv/", p);
}
-print("Finishing sfile\n");
- } else if(strncmp(p, "stubs", 5) == 0){
-print("Starting stubs\n");
+print("Out of Sfile\n");
+ }
+ if(strncmp(p, "stubs", 5) == 0){
+print("Stubby\n");
p = strip(p + 5);
if(*p == '='){
p = strip(p + 1);
conf->stubs = fromCSV(p, &conf->nstub);
if(!conf->stubs){
+ Bterm(f);
freeconf(conf);
free(ln);
return nil;
}
}
-print("Finishing stubs\n");
- } else {
- // TBD
+print("Out of stubby\n");
}
free(ln);
}
+ Bterm(f);
if(!conf->sfile)
conf->sfile = wd2sfile();
return conf;
--- a/mkfile
+++ b/mkfile
@@ -7,6 +7,7 @@
RC=\
init\
+ add\
OFILES=\
conf.$O\
--- a/ns.c
+++ b/ns.c
@@ -19,17 +19,18 @@
if(argc != 1)
usage(argv[0]);
-
conf = pconf();
if(conf == nil){
fprint(2, "can't parse: %r\n");
exits("config");
}
- for(i = 0; i < conf->nstub; i++)
-print("%s\n", conf->stubs[i]);
-exits(0);
- // execl("/bin/aux/stub", "-d", conf->stubs[i]);
-
+ for(i = 0; i < conf->nstub; i++){
+ print(conf->stubs[i]);
+ if(rfork(RFPROC|RFNOWAIT|RFNOTEG|RFNAMEG) == 0){
+ execl("/bin/aux/stub", "aux/stub", "-d", conf->stubs[i]);
+ fprint(2, "can't exec aux/stub: %r\n");
+ }
+ }
if(addns(getuser(), ".pro/ns") < 0){
fprint(2, "can't addns: %r\n");
exits("addns");
@@ -49,8 +50,7 @@
fprint(fd, "%d", pipefd[1]);
close(pipefd[1]);
freeconf(conf);
-
- switch(rfork(RFPROC|RFNOWAIT|RFNOTEG|RFFDG)){
+ switch(rfork(RFPROC|RFNOWAIT|RFNOTEG|RFREND)){
case -1:
fprint(2, "can't rfork: %r\n");
exits("rfork");
--- /dev/null
+++ b/rm
@@ -1,0 +1,33 @@
+#!/bin/rc -e
+rfork ne
+
+fn checkstate {
+ if(! ~ $#all 0){
+ if(! ~ $#force 0)
+ rmlist=`{ls .pro/todo}
+ if not
+ rmlist=`{pro/walk -c -fC}
+ }
+ if not {
+ if(! ~ $#force 0)
+ rmlist=`{ls .pro/todo/$tag}
+ if not
+ rmlist=`{pro/walk -q fC $tag && ls .pro/todo/$tag}
+ }
+}
+
+fn rmtask {
+ for(m in $rmlist)
+ rm $m
+}
+
+flagfmt='f:force, a:all'; args='tag'
+eval `''{aux/getflags $*} || exec aux/usage
+rmlist=()
+tag=$1
+@{
+ flag e +
+ checkstate
+ rmtask
+} || echo 'could not rm task:' $status >[1=2]
+exit ''