[Top][All Lists]

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

Re: Bug: different behavior between "jobs -l" and "builtin jobs -l"

From: Martijn Dekker
Subject: Re: Bug: different behavior between "jobs -l" and "builtin jobs -l"
Date: Tue, 21 Mar 2017 19:32:27 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.7.1

Op 21-03-17 om 18:08 schreef Greg Wooledge:
> A builtin is always used by preference over an external command of the
> same name.  You don't need to specify "builtin jobs" to be sure you're
> using the builtin.  Just use "jobs".
> The only time you need to use the "builtin" command is when you're
> defining a function by the same name, and you want bash to use its
> builtin instead of your function.

You may also need to use it if you're writing a function or script used
by another program you don't control, or in another user's interactive
shell environment. In that case you have no way to be sure whether
'jobs' might already be used as an alias or function name.

A workaround for the original poster's problem could be:

        (unset -f jobs; unalias jobs; eval 'jobs -l') | wc

The 'eval' is to stop the alias from being expanded at parse time before
you have a chance to unalias it. This should be about as robust as
running 'builtin jobs -l', except it still doesn't check whether the
builtin might have been disabled.

- M.

reply via email to

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