delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/01/06/21:52:41

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3E1A2EFB.4020006@hack.kampbjorn.com>
Date: Tue, 07 Jan 2003 02:35:55 +0100
From: Hack Kampbjorn <cygwin AT hack DOT kampbjorn DOT com>
Reply-To: cygwin AT cygwin DOT 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 AT cygwin DOT com
Subject: Re: nohup broken in sh-utils-2.0.15-2
References: <3 DOT 0 DOT 5 DOT 32 DOT 20030106142926 DOT 00a87ae0 AT mscmail DOT gsfc DOT nasa DOT gov>
In-Reply-To: <3.0.5.32.20030106142926.00a87ae0@mscmail.gsfc.nasa.gov>

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019