Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: fg jobs info



maybe in the process of working out the bugs, there can be some added functionality to add a variable that automagically returns the text of the fg'd job.

in the meantime, i'm keeping it (relatively) simple and assuming that i've only got one job at a time suspended (for me, that's a reasonable assumption; YMMV). my preexec runs a function (to display the command name in tabs, title bars, icons, etc), and part of the function is simply:

    if [ 'fg' = "${${(z)@}[1]}" ]
    then
      cmnd_name="${(vV)jobtexts}"
    fi

as far as i can tell, the worst case failure is that it will display the commands of more than one job. considering the lengths i'd have to go through to fix that, and the chances of introducing more bugs, and how often i have multiple jobs suspended within a shell (not very often) i think this is good enough, for now.

thanks...


On Tue, 4 Sep 2007, Bart Schaefer wrote:

You're right. $(jobs) and (jobs) produce different output. I thought that because the latter worked, the former would also.

Looks to me as if there's a bug here; compare

   print $(jobs)
   (print $(jobs))

Also, although "jobs" or "jobs -l" prints out the entire jobs listing
even in subshells/pipelines/etc., "jobs %2" (for example) produces a
"no such job" error, which surprised me.  That should at least be
documented.  Try:

   sleep 40 & sleep 30 &
   jobs | cat
   jobs %1 | cat

So the easy way out is not going to work here after all.

~~~~~~~~~~~

Incidentally, yet another bug:

   % sleep 30 & sleep 50 &
   % fg %- %-
   [1]  - running    sleep 30
   fg: %3: no such job

Where did I ever ask for job 3 ?



--
        ...atom

 ________________________
 http://atom.smasher.org/
 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
 -------------------------------------------------

        "Human beings, who are almost unique in having the ability
         to learn from the experience of others, are also remarkable
         for their apparent disinclination to do so."
                -- Douglas Adams, Last Chance to See



Messages sorted by: Reverse Date, Date, Thread, Author