2023年2月15日(水) 0:51 Chet Ramey <chet.ra...@case.edu>: > On 2/11/23 11:14 AM, Koichi Murase wrote: > > 2023年2月12日(日) 0:42 Robert Elz <k...@munnari.oz.au>: > >> Why would you want to ever say "builtin jobs" though? > >> The jobs command has to be buikt in to work. > > > > `jobs' can be overwritten by a shell function. For example, when a > > user wants to modify the behavior of `jobs' for interactive uses, a > > typical solution is to override `jobs' with a shell function and call > > `builtin jobs' in the overriding function. > > > > I guessed you have asked this because `jobs' would be specified as a > > special built-in utility [XCU 2.14], which cannot be hidden by a > > shell-function name, but it doesn't seem to be the case actually; > > There's no way `jobs' would ever be a special builtin. It's always been > UPE shaded (User Portability). Job control wasn't even mandatory in > POSIX until Issue 6 (2004), and the specification that jobs can be run > when job control isn't enabled came well after that.
Thank you for the information. I find it interesting to hear about the historical background. The statement about the special built-in was just my initial guess for the reason why kre seemed to claim that `builtin jobs' is equivalent to `jobs', but I just checked the standard and immediately knew my guess was incorrect. I still don't think `builtin jobs' is equivalent to `jobs' because `jobs' can pick up a shell function. > > I naively think that it is a valid request that `builtin jobs' would > > behave in the same way as `jobs' in this context. POSIX also states > > that the results are unspecified when the command name matches > > `builtin' according to [XCU 2.9.1 / Command Search and Execution / > > rule 1b]. > > Whether or not `builtin' is specified by POSIX isn't really relevant. That > list just means that some shells have implemented `builtin' as a builtin > command, so portable applications should take care with it. I just meant that even if Bash treats `builtin jobs' the same as `jobs' in these particular subshell contexts, it doesn't conflict with POSIX. So, POSIX seems to be irrelevant when we think about the behavior when `builtin' is involved.