9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
@ 2008-10-28  9:42 Rudolf Sykora
  2008-10-28 10:04 ` Steve Simon
  2008-10-28 10:54 ` matt
  0 siblings, 2 replies; 13+ messages in thread
From: Rudolf Sykora @ 2008-10-28  9:42 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello

I encountered sth strange:

being e.g. in my home

; pwd
/usr/ruda

I issue
; @{cd lib}

then lc, pwd seems to be ok, lists/returns my home directory, but the
completion with ctrl-f/ins proposes things from the 'lib' directory.
What's going on? I really can't live without the completion function...
'cd .' doesn't help, only 'cd $home' does... Only then the completion
functions again...
Hope this will work the same for you too.
If you know, please tell me soon.

Ruda



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28  9:42 [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed Rudolf Sykora
@ 2008-10-28 10:04 ` Steve Simon
  2008-10-28 15:14   ` Rudolf Sykora
  2008-10-28 10:54 ` matt
  1 sibling, 1 reply; 13+ messages in thread
From: Steve Simon @ 2008-10-28 10:04 UTC (permalink / raw)
  To: 9fans

> I issue
> ; @{cd lib}
>
> then lc, pwd seems to be ok, lists/returns my home directory,

This makes sense to me - though I am not saying its "correct".

When you cd in interactive mode rc(1) writes the path to the
directory into /dev/wdir. This informs rio of your current dir
so it can do the filename completion (and also gives the directory
context to the plumber).

I guess the @{ } "execute in a subshell" code in rc could save and restore
the current directory, however this is only an issue in interactive mode.
I have never needed @{ } interactively so I have not had this problem.

probably the best way to get things back in sync is:

	cd `{pwd}

-Steve



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28  9:42 [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed Rudolf Sykora
  2008-10-28 10:04 ` Steve Simon
@ 2008-10-28 10:54 ` matt
  2008-10-28 15:15   ` Rudolf Sykora
  1 sibling, 1 reply; 13+ messages in thread
From: matt @ 2008-10-28 10:54 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Rudolf Sykora wrote:
> > I really can't live without the completion function...

how come? I've *never* used it



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 10:04 ` Steve Simon
@ 2008-10-28 15:14   ` Rudolf Sykora
  2008-10-28 15:30     ` Rob Pike
  2008-10-28 21:17     ` Lyndon Nerenberg
  0 siblings, 2 replies; 13+ messages in thread
From: Rudolf Sykora @ 2008-10-28 15:14 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> When you cd in interactive mode rc(1) writes the path to the
> directory into /dev/wdir. This informs rio of your current dir
> so it can do the filename completion (and also gives the directory
> context to the plumber).
>
> I guess the @{ } "execute in a subshell" code in rc could save and restore
> the current directory, however this is only an issue in interactive mode.
> I have never needed @{ } interactively so I have not had this problem.

This saving&restoring seems flawed to me due to possible race-conditions...
I'd expect each shell had its own copy of /dev/wdir... But I may be
easily wrong...

> probably the best way to get things back in sync is:
>
>        cd `{pwd}
>
> -Steve

yes, that works
Ruda



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 10:54 ` matt
@ 2008-10-28 15:15   ` Rudolf Sykora
  0 siblings, 0 replies; 13+ messages in thread
From: Rudolf Sykora @ 2008-10-28 15:15 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2008/10/28 matt <mattmobile@proweb.co.uk>:
> Rudolf Sykora wrote:
>>
>> > I really can't live without the completion function...
>
> how come? I've *never* used it

... this is hard to comment on...
Ruda



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 15:14   ` Rudolf Sykora
@ 2008-10-28 15:30     ` Rob Pike
  2008-10-28 16:27       ` Rudolf Sykora
  2008-10-28 21:17     ` Lyndon Nerenberg
  1 sibling, 1 reply; 13+ messages in thread
From: Rob Pike @ 2008-10-28 15:30 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

cd .

is sufficient

-rob



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 15:30     ` Rob Pike
@ 2008-10-28 16:27       ` Rudolf Sykora
  2008-10-28 17:16         ` andrey mirtchovski
  2008-10-28 17:21         ` Russ Cox
  0 siblings, 2 replies; 13+ messages in thread
From: Rudolf Sykora @ 2008-10-28 16:27 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> cd .
>
> is sufficient
>
> -rob

As I wrote in my initial mail, 'cd .' does not help.
Ruda



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 16:27       ` Rudolf Sykora
@ 2008-10-28 17:16         ` andrey mirtchovski
  2008-10-28 17:26           ` andrey mirtchovski
  2008-10-28 17:21         ` Russ Cox
  1 sibling, 1 reply; 13+ messages in thread
From: andrey mirtchovski @ 2008-10-28 17:16 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

the bug is within rio, which keeps track of changed directories but
doesn't know that some of them are changed on a stack for a child
process. the actual code is in xfid.c:^xfidwrite, the Qwdir case. what
is happening is that it catches the 'cd /lib' correctly and sets
w->dir accordingly, however the subsequent 'cd .' is interpreted as a
local unrooted path (doesn't start with '/') and the dot is appended
to the current w->dir. cleanname() subsequently just remove the dot,
leaving the old w->dir to be supplied to 'complete'.

two solutions:
- use getpw() instead of w->dir for unrooted arguments to cd (the
return value of getpw() is correct after the subshell command
completes)
- use 'cd `{pwd}' instead of 'cd .'... this will give a rooted
argument to 'cd' and rio will reset the whole w->dir

andrey

On Tue, Oct 28, 2008 at 10:27 AM, Rudolf Sykora <rudolf.sykora@gmail.com> wrote:
>> cd .
>>
>> is sufficient
>>
>> -rob
>
> As I wrote in my initial mail, 'cd .' does not help.
> Ruda
>
>



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 16:27       ` Rudolf Sykora
  2008-10-28 17:16         ` andrey mirtchovski
@ 2008-10-28 17:21         ` Russ Cox
  1 sibling, 0 replies; 13+ messages in thread
From: Russ Cox @ 2008-10-28 17:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> As I wrote in my initial mail, 'cd .' does not help.

pwd >/dev/wdir

cd . works for fixing acme's tag (if your cd runs awd)
but not for fixing /dev/wdir, because rc just writes the
argument to cd uninterpreted into /dev/wdir, and
/dev/wdir interprets paths relative to the current wdir setting.

It's a hard problem in general, since the shell has
no idea whether the program that just ran changed
/dev/wdir.  The only way to keep it in sync would
be to force the shell to write into /dev/wdir after
every command completed, which would be overkill.

Russ


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 17:16         ` andrey mirtchovski
@ 2008-10-28 17:26           ` andrey mirtchovski
  0 siblings, 0 replies; 13+ messages in thread
From: andrey mirtchovski @ 2008-10-28 17:26 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> - use getpw() instead of w->dir for unrooted arguments to cd (the
> return value of getpw() is correct after the subshell command
> completes)

scratch that, it is incorrect. i only tried getpw() from the shell.
rio doesn't necessarily live in the same world as the shells in its
windows.

thanks to Russ for promptly correcting me.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 15:14   ` Rudolf Sykora
  2008-10-28 15:30     ` Rob Pike
@ 2008-10-28 21:17     ` Lyndon Nerenberg
  2008-10-28 21:41       ` Rudolf Sykora
  1 sibling, 1 reply; 13+ messages in thread
From: Lyndon Nerenberg @ 2008-10-28 21:17 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> This saving&restoring seems flawed to me due to possible race-conditions...
> I'd expect each shell had its own copy of /dev/wdir... But I may be
> easily wrong...

When a rc forks a subshell the child shares the namespace with the parent.
If you want the child rc to divorce its namespace from the parent, have it
issue 'rfork n'.

There is no race condition; this is documented behaviour.

You need to (re-)read the namespaces paper in /sys/doc/names.ps.

--lyndon



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 21:17     ` Lyndon Nerenberg
@ 2008-10-28 21:41       ` Rudolf Sykora
  2008-10-28 22:24         ` Lyndon Nerenberg
  0 siblings, 1 reply; 13+ messages in thread
From: Rudolf Sykora @ 2008-10-28 21:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> When a rc forks a subshell the child shares the namespace with the parent.
> If you want the child rc to divorce its namespace from the parent, have it
> issue 'rfork n'.

This is true, but I am afraid it doesn't have much connection to the problem.
Even if you 'rfork n' (and have a copy of the namespace) the file
/dev/wdir is simply the same file in both namespaces...
Ruda



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed
  2008-10-28 21:41       ` Rudolf Sykora
@ 2008-10-28 22:24         ` Lyndon Nerenberg
  0 siblings, 0 replies; 13+ messages in thread
From: Lyndon Nerenberg @ 2008-10-28 22:24 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> This is true, but I am afraid it doesn't have much connection to the problem.
> Even if you 'rfork n' (and have a copy of the namespace) the file
> /dev/wdir is simply the same file in both namespaces...

Yes, I realized after I hit send that I wasn't very clear about what I was
trying to say. I wasn't trying to address the wdir issue, but your
allusion to the namespace behaviour not making sense. Knowing how
and why namespaces work as they do is critical to understanding and using
Plan 9. It's important that you read and understand the names.ps paper and
then spend time experimenting with namespaces. For most people it's the
hardest part of the system to wrap your brain around, but once you get it
your universe gets a lot bigger very quickly.

--lyndon



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-10-28 22:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-28  9:42 [9fans] @{cd ...} breaks completion with ctrl-f/ins; help needed Rudolf Sykora
2008-10-28 10:04 ` Steve Simon
2008-10-28 15:14   ` Rudolf Sykora
2008-10-28 15:30     ` Rob Pike
2008-10-28 16:27       ` Rudolf Sykora
2008-10-28 17:16         ` andrey mirtchovski
2008-10-28 17:26           ` andrey mirtchovski
2008-10-28 17:21         ` Russ Cox
2008-10-28 21:17     ` Lyndon Nerenberg
2008-10-28 21:41       ` Rudolf Sykora
2008-10-28 22:24         ` Lyndon Nerenberg
2008-10-28 10:54 ` matt
2008-10-28 15:15   ` Rudolf Sykora

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).