bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: jobs cmd returns * instead or file name


From: Chet Ramey
Subject: Re: jobs cmd returns * instead or file name
Date: Fri, 15 Feb 2002 13:27:44 -0500

> Machine Type: i586-mandrake-linux-gnu
> 
> Bash Version: 2.05
> Patch Level: 1
> Release Status: release
> 
> Description:
>       when I use for example:
>          function te(){ nedit $@ & }
>          te kuku
>          jobs
>       I get as the output of the "jobs" command:
>          [1]+  Running                 nedit $@ &
>       i.e., instead of returning the file name it gives the "$@" string, 
> which is 
> *not* what I wanted- how can I know which job is which if I have several 
> "te"s running? BTW, the same thing happens if I choose emacs instead of 
> nedit...

When a simple command is run asynchronously, the subshell is forked before
the command is expanded, so any assignment statements that are performed
as part of the expansion don't affect the parent shell's environment.

The `job name' is set when the job is created -- that is, when the child
process is created.  At that time, since expansion has not been performed,
the job name is still `nedit $@'.  Since the child process handles the
expansion, there's no way for the parent to change the job name.

It's admittedly sub-optimal, but I'd rather have correct behavior with 
respect to the separation between parent and child execution contexts.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]