NetBSD Problem Report #41836
From www@NetBSD.org Fri Aug 7 07:46:28 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 787FD63C270
for <gnats-bugs@gnats.netbsd.org>; Fri, 7 Aug 2009 07:46:28 +0000 (UTC)
Message-Id: <20090807074627.ECA1063BDF9@www.NetBSD.org>
Date: Fri, 7 Aug 2009 07:46:27 +0000 (UTC)
From: ekamperi@gmail.com
Reply-To: ekamperi@gmail.com
To: gnats-bugs@NetBSD.org
Subject: jobs -l %% doesn't work when called from a script
X-Send-Pr-Version: www-1.0
>Number: 41836
>Category: bin
>Synopsis: jobs -l %% doesn't work when called from a script
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Aug 07 07:50:00 +0000 2009
>Originator: Stathis Kamperis
>Release: NetBSD 5.0_STABLE
>Organization:
Aristotle University of Thessaloniki
>Environment:
[stathis@voyager ~] uname -a
NetBSD voyager 5.0_STABLE NetBSD 5.0_STABLE (MYGENERIC) #9: Wed Aug 5 00:38:20 EEST 2009 root@voyager:/usr/obj/sys/arch/i386/compile/MYGENERIC i386
>Description:
jobs -l %% and jobs -l %+ don't work when they are used inside a script.
Whereas they work when invoked by an interactive shell.
>How-To-Repeat:
INTERACTIVE SHELL
-----------------
[stathis@voyager ~] sleep 100 &
[1] 22149
[stathis@voyager ~] jobs -l %%
[1]+ 22149 Running sleep 100 &
[stathis@voyager ~] jobs -l %+
[1]+ 22149 Running sleep 100 &
[stathis@voyager ~]
SCRIPT
------
[stathis@voyager ~] cat lala.sh
#!/bin/sh
sleep 100 &
f=$(jobs -l %%)
echo "$f"
[stathis@voyager ~] ./lala.sh
<---- an empty line is printed
[stathis@voyager ~]
Same applies to $(jobs -l %+).
What is interesting is that... if you put %- (which denotes the previous job), the scripts outputs the sleep job.
[stathis@voyager ~] cat lala.sh
#!/bin/sh
sleep 100 &
f=$(jobs -l %-)
echo "$f"
[stathis@voyager ~] ./lala.sh
[1] - 12972 Running sleep 100 <---- there shouldn't be a 'minus' sign here. This should be '+', since sleep is the only and current job.
[stathis@voyager ~]
Linux, Solaris 10 and DragonFlyBSD get it right (%% and %+ list the sleep job).
>Fix:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.