[9fans] window -hide rc -c 'label a_name; tail -f some_file' - Plan9

This is a discussion on [9fans] window -hide rc -c 'label a_name; tail -f some_file' - Plan9 ; Hello, I'd expect window -hide rc -c 'label a_name; tail -f some_file' would create a new hidden window (and so it does), run the tail command (and so it does) and set the name for the hidden window to a_name. ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: [9fans] window -hide rc -c 'label a_name; tail -f some_file'

  1. [9fans] window -hide rc -c 'label a_name; tail -f some_file'

    Hello,

    I'd expect

    window -hide rc -c 'label a_name; tail -f some_file'

    would create a new hidden window (and so it does), run the tail command (and
    so it does) and set the name for the hidden window to a_name.
    The last thing seems to not happen (at least from the viewpoint of using the
    button-3 menu in rio --- I only see an empty field, i. e. without any name).
    Can anyone tell me what's wrong?

    Thanks
    Ruda


  2. Re: [9fans] window -hide rc -c 'label a_name; tail -f some_file'

    see the window(1) man page regarding the -m option passed to the
    command and what it does in this case. not to repeat everything here,
    but it suffices to say that

    window -m -hide rc -c 'label a_name; tail -f /sys/log/telnet'

    works as expected.

    note that -m must appear first in the argument list. you can consider
    this a bug if you'd like.

    On Wed, Oct 8, 2008 at 12:26 PM, Rudolf Sykora wrote:
    > Hello,
    >
    > I'd expect
    >
    > window -hide rc -c 'label a_name; tail -f some_file'
    >
    > would create a new hidden window (and so it does), run the tail command (and
    > so it does) and set the name for the hidden window to a_name.
    > The last thing seems to not happen (at least from the viewpoint of using the
    > button-3 menu in rio --- I only see an empty field, i. e. without any name).
    > Can anyone tell me what's wrong?
    >
    > Thanks
    > Ruda
    >



  3. Re: [9fans] window -hide rc -c 'label a_name; tail -f some_file'

    On Oct 8, 2008, at 2:26 PM, Rudolf Sykora wrote:

    > Hello,
    >
    > I'd expect
    >
    > window -hide rc -c 'label a_name; tail -f some_file'
    >
    > would create a new hidden window (and so it does), run the tail
    > command (and so it does) and set the name for the hidden window to
    > a_name.
    > The last thing seems to not happen (at least from the viewpoint of
    > using the button-3 menu in rio --- I only see an empty field, i. e.
    > without any name).
    > Can anyone tell me what's wrong?
    >
    > Thanks
    > Ruda


    rc -c only runs the commands given and then terminates. When all the
    processes given to window terminates, the window closes. That's what's
    happening to you. Try this:

    window -hide 'label a_name; tail -f some_file; rc'



  4. Re: [9fans] window -hide rc -c 'label a_name; tail -f some_file'

    window -hide rc -c 'label a_name; tail -f some_file'
    >>
    >>

    > rc -c only runs the commands given and then terminates. When all the
    > processes given to window terminates, the window closes. That's what's
    > happening to you. Try this:
    >
    > window -hide 'label a_name; tail -f some_file; rc'



    First, it does not terminate, as you could easily try (thanks to the -f
    switch of tail).
    Second, your proposal does not work any better than mine.
    R.


  5. Re: [9fans] window -hide rc -c 'label a_name; tail -f some_file'

    2008/10/8 andrey mirtchovski

    > see the window(1) man page regarding the -m option passed to the
    > command and what it does in this case. not to repeat everything here,
    > but it suffices to say that
    >
    > window -m -hide rc -c 'label a_name; tail -f /sys/log/telnet'
    >
    > works as expected.
    >
    > note that -m must appear first in the argument list. you can consider
    > this a bug if you'd like.



    Thanks. It really works. I read about that -m option again. I've actually
    already used it before. But somehow I still don't understand why it helps...
    What if I (for some reason) don't want the namespace to be copied?
    R.


  6. Re: [9fans] window -hide rc -c 'label a_name; tail -f some_file'

    scratch my previous explanation. it is incorrect. looking through
    rio's source code it appears that the cause is the supplied "rc -c"
    argument to 'window'. the window command assumes that everything after
    the switches is a command to be executed and actually prepends 'rc -c'
    in front of your command line. due to quoting and other mishaps, the
    end effect is that the command as specified (i'm testing with "sleep"
    instead of "tail -f") is executed as:

    rc -c 'rc -c label test; sleep 20' (quoting as per the rio window manager)

    instead, you should probably just do:

    window 'label test; sleep 20', which will be executed as:

    rc -c 'label test; sleep 20'

    and will work fine even without the -m switch.

    you can see for yourself the described behaviour via the following
    test on a plain shell (all execute commands to be run without the
    double quotes):

    1: execute "rc -c 'label test; sleep 20'"
    2: hide the window (you'll see the label 'test')
    3: unhide the window and terminate the sleep
    4: execute "rc -c 'rc -c label test; sleep 20'"
    5: hide the window (you'll see an empty entry for the window label)
    6: unhide the window. notice that the label remains empty even after
    the sleep has completed

    finally, try a fully escaped shell to see that it works:
    7: execute "rc -c 'rc -c ''label test; sleep 20'''"
    8: hide the window

    why rc behaves this way is a different matter altogether. i'll leave
    it to you, but i encourage you to dig in the source. i figured all
    this out after editing the rio source and adding a piece of code to
    print me the argument list it executes for a new window. i doubt
    you'll ever find an easier source to deal with than on plan9. rio is
    only 5K lines of code and acme makes navigation through that code a
    bliss. same goes for almost everything else in the system.


  7. Re: [9fans] window -hide rc -c 'label a_name; tail -f some_file'

    2008/10/8 andrey mirtchovski

    > scratch my previous explanation. it is incorrect. looking through
    > rio's source code it appears that the cause is the supplied "rc -c"
    > argument to 'window'. the window command assumes that everything after
    > the switches is a command to be executed and actually prepends 'rc -c'
    > in front of your command line. due to quoting and other mishaps, the
    > end effect is that the command as specified (i'm testing with "sleep"
    > instead of "tail -f") is executed as:
    >
    > rc -c 'rc -c label test; sleep 20' (quoting as per the rio window manager)
    >
    > instead, you should probably just do:
    >
    > window 'label test; sleep 20', which will be executed as:
    >
    > rc -c 'label test; sleep 20'
    >
    > and will work fine even without the -m switch.
    >
    > you can see for yourself the described behaviour via the following
    > test on a plain shell (all execute commands to be run without the
    > double quotes):
    >
    > 1: execute "rc -c 'label test; sleep 20'"
    > 2: hide the window (you'll see the label 'test')
    > 3: unhide the window and terminate the sleep
    > 4: execute "rc -c 'rc -c label test; sleep 20'"
    > 5: hide the window (you'll see an empty entry for the window label)
    > 6: unhide the window. notice that the label remains empty even after
    > the sleep has completed
    >
    > finally, try a fully escaped shell to see that it works:
    > 7: execute "rc -c 'rc -c ''label test; sleep 20'''"
    > 8: hide the window
    >
    > why rc behaves this way is a different matter altogether. i'll leave
    > it to you, but i encourage you to dig in the source. i figured all
    > this out after editing the rio source and adding a piece of code to
    > print me the argument list it executes for a new window. i doubt
    > you'll ever find an easier source to deal with than on plan9. rio is
    > only 5K lines of code and acme makes navigation through that code a
    > bliss. same goes for almost everything else in the system.
    >
    > Thanks a lot. I probably just wouldn't be able to find that I'll try and

    go through the code myself.
    Just one last question concerning this. Is it the right, expected behaviour
    of the window command, or should the original version work and sth. should
    be changed?
    Ruda


+ Reply to Thread