* [9fans] acme tags for shell scripts
@ 2004-10-14 13:28 Gorka Guardiola
2004-10-14 14:39 ` Russ Cox
0 siblings, 1 reply; 5+ messages in thread
From: Gorka Guardiola @ 2004-10-14 13:28 UTC (permalink / raw)
To: 9fans
I was trying to access the tag of the current window on acme from a
shell script and found it impossible. The problem is that there is no
way to get back the id of the current window (the one the script is
run on) in the shell script in order to access to /dev/wsys/%d. I have
looked the way win does it (binding the current window on /dev/wsys/id
and done it for every script run in acme). It is a little change,
which makes ID obsolete (it can be a shell script now), and makes
scripts on acme more powerful. It doesn't seem to break anything.
What do you think about it?. Does it break anything, is it
necessary?. Is there anything I haven't seen?.
I will create a patch tonight as I don't have time now, but the
diff is very simple... (I haven't taken ID out yet, that will take
some more work as I am not that familiar with acme).
term% yesterday -D /sys/src/cmd/acme
post...
diff -n /n/dump/2004/1014/sys/src/cmd/acme /sys/src/cmd/acme
diff -n /n/dump/2004/1014/sys/src/cmd/acme/exec.c /sys/src/cmd/acme/exec.c
/n/dump/2004/1014/sys/src/cmd/acme/exec.c:1206 c /sys/src/cmd/acme/exec.c:1206
< c->md = fsysmount(rdir, ndir, incl, nincl);
---
> c->md = fsysmount(rdir, ndir, incl, nincl, win->id);
diff -n /n/dump/2004/1014/sys/src/cmd/acme/fns.h /sys/src/cmd/acme/fns.h
/n/dump/2004/1014/sys/src/cmd/acme/fns.h:66 c /sys/src/cmd/acme/fns.h:66
< Mntdir* fsysmount(Rune*, int, Rune**, int);
---
> Mntdir* fsysmount(Rune*, int, Rune**, int, int);
diff -n /n/dump/2004/1014/sys/src/cmd/acme/fsys.c /sys/src/cmd/acme/fsys.c
/n/dump/2004/1014/sys/src/cmd/acme/fsys.c:246 c /sys/src/cmd/acme/fsys.c:246
< fsysmount(Rune *dir, int ndir, Rune **incl, int nincl)
---
> fsysmount(Rune *dir, int ndir, Rune **incl, int nincl, int winid)
/n/dump/2004/1014/sys/src/cmd/acme/fsys.c:248 c /sys/src/cmd/acme/fsys.c:248
< char buf[256];
---
> char buf[256], *wpath;
/n/dump/2004/1014/sys/src/cmd/acme/fsys.c:264 a /sys/src/cmd/acme/fsys.c:265,270
> wpath=smprint("/mnt/acme/%d", winid);
> if(bind(wpath, "/dev/acme", MBEFORE) < 0){
> fsysdelid(m);
> return nil;
> }
> free(wpath);
An example of use of this (for the tags program by nemo) is using T tag to mark
the current file:
#!/bin/rc
acmepath=`{cat /dev/acme/tag|awk '{print $1}'}
if(~ $#* 0){
grep -n $acmepath $home/lib/*.tags
}
if not{
tag/Tag $acmepath $*
}
ID as a shell script:
#!/bin/rc
cat /dev/acme/ctl|awk '{print $1}'
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] acme tags for shell scripts
2004-10-14 13:28 [9fans] acme tags for shell scripts Gorka Guardiola
@ 2004-10-14 14:39 ` Russ Cox
2004-10-14 14:47 ` Gorka Guardiola
0 siblings, 1 reply; 5+ messages in thread
From: Russ Cox @ 2004-10-14 14:39 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> I was trying to access the tag of the current window on acme from a
> shell script and found it impossible. The problem is that there is no
> way to get back the id of the current window (the one the script is
> run on) in the shell script in order to access to /dev/wsys/%d.
cat /mnt/acme/$winid/tag works. Your solution may be cleaner,
but the task isn't currently impossible.
Russ
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] acme tags for shell scripts
2004-10-14 14:39 ` Russ Cox
@ 2004-10-14 14:47 ` Gorka Guardiola
2004-10-15 13:27 ` Russ Cox
0 siblings, 1 reply; 5+ messages in thread
From: Gorka Guardiola @ 2004-10-14 14:47 UTC (permalink / raw)
To: russcox, 9fans
>> I was trying to access the tag of the current window on acme from a
>> shell script and found it impossible. The problem is that there is no
>> way to get back the id of the current window (the one the script is
>> run on) in the shell script in order to access to /dev/wsys/%d.
>
> cat /mnt/acme/$winid/tag works. Your solution may be cleaner,
> but the task isn't currently impossible.
Yes, I realized it when Forsyth said it. I thought this was impossible,
so I did this change. I wouldn't have done it if I knew the wsys (by the
way, is there any reference in the manual about it?).
Looking at it now, I seems cleaner as you said.
The problem here is that this mechanisms are not uniform. In rio, /dev/winid is
the current id of the window. In an script run in acme this is done
with $winid. In win (in acme) the dir is bound in /dev/acme. Wouldn't all this
have to be the same?.
G.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] acme tags for shell scripts
2004-10-14 14:47 ` Gorka Guardiola
@ 2004-10-15 13:27 ` Russ Cox
2004-10-15 13:54 ` Gorka Guardiola
0 siblings, 1 reply; 5+ messages in thread
From: Russ Cox @ 2004-10-15 13:27 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> The problem here is that this mechanisms are not uniform. In rio, /dev/winid is
> the current id of the window. In an script run in acme this is done
> with $winid. In win (in acme) the dir is bound in /dev/acme. Wouldn't all this
> have to be the same?.
It's true that they're not uniform. I'm not sure what you mean by
"have to be the same". It would definitely be confusing if /dev/winid
gave you acme id's under acme but rio id's under rio.
I agree if you mean that all the context should be in the name
space where it belongs.
The reason acme sets $winid is that I put it in (originally for
the Getdir script, which replaced the builtin Dotfiles) while
I was using the Unix acme, and there I don't have the luxury
of per-process name spaces, but I do have per-process environments.
I'll probably add your bind next time I'm in there.
Russ
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] acme tags for shell scripts
2004-10-15 13:27 ` Russ Cox
@ 2004-10-15 13:54 ` Gorka Guardiola
0 siblings, 0 replies; 5+ messages in thread
From: Gorka Guardiola @ 2004-10-15 13:54 UTC (permalink / raw)
To: russcox, 9fans
> It's true that they're not uniform. I'm not sure what you mean by
> "have to be the same". It would definitely be confusing if /dev/winid
> gave you acme id's under acme but rio id's under rio.
Yes, I meant uniform.
> I agree if you mean that all the context should be in the name
> space where it belongs.
>
> The reason acme sets $winid is that I put it in (originally for
> the Getdir script, which replaced the builtin Dotfiles) while
It should be in the man page anyway.
term% man acme|grep [Ww]inid
term%
> I was using the Unix acme, and there I don't have the luxury
> of per-process name spaces, but I do have per-process environments.
>
> I'll probably add your bind next time I'm in there.
It would also be good after that to get rid of ID.
G.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-10-15 13:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-14 13:28 [9fans] acme tags for shell scripts Gorka Guardiola
2004-10-14 14:39 ` Russ Cox
2004-10-14 14:47 ` Gorka Guardiola
2004-10-15 13:27 ` Russ Cox
2004-10-15 13:54 ` Gorka Guardiola
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).