Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Message-ID: <3E1A2EFB.4020006@hack.kampbjorn.com>
Date: Tue, 07 Jan 2003 02:35:55 +0100
From: Hack Kampbjorn <cygwin@hack.kampbjorn.com>
Reply-To: cygwin@cygwin.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130
X-Accept-Language: en,da,es,ca
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: nohup broken in sh-utils-2.0.15-2
References: <3.0.5.32.20030106142926.00a87ae0@mscmail.gsfc.nasa.gov>
In-Reply-To: <3.0.5.32.20030106142926.00a87ae0@mscmail.gsfc.nasa.gov>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Michael A Richmond wrote:
> When I run nohup from sh-utils-2.0.15-2, I get the message
> 
> exec: --: not found
> 
> The version of nohup in sh-utils-2.0-3 does not produce this error.

The problematic line in nohup is the last one: exec -- "$@"
In sh-utils-2.0 this was: exec "$niceprog" -5 -- "$@"
Given that exec is a shell builtin and nohup is run under /bin/sh which 
should be ash.

Extract from the ash man page:
exec [ command arg...  ]
      Unless command is omitted, the shell process is replaced with  the
      specified  program  (which  must  be  a  real program, not a shell
      builtin or function).  Any redirections on the  exec  command  are
      marked  as  permanent,  so  that they are not undone when the exec
      command finishes.  If the command is not found, the  exec  command
      causes the shell to exit.

So removing the -- command protection as ash's exec doesn't take any 
options fixes the problem (and keychain works again).

But if bash has been copied to /bin/sh then there will be a problem for 
commands with a leading dash.

Extract from the bash man page:
exec [-cl] [-a name] [command [arguments]]
       ...

But testing for this and setting a shellvariable according seems to fix 
it for both ash and bash.

--- /usr/bin/nohup.orig 2003-01-05 04:15:00.000000000 +0100
+++ /usr/bin/nohup      2003-01-07 02:32:59.000000000 +0100
@@ -76,4 +76,6 @@
    exec 2>&1
  fi

-exec -- "$@"
+DD=`(exec -l echo "--" 2>/dev/null)`
+
+exec $DD "$@"

-- 
Med venlig hilsen / Kind regards

Hack Kampbjørn


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

