NetBSD-Bugs archive

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

Re: bin/45430: ash uses argv[0] as $0 for scripts without #!



The following reply was made to PR bin/45430; it has been noted by GNATS.

From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/45430: ash uses argv[0] as $0 for scripts without #!
Date: Sun, 6 Nov 2011 00:48:10 +0000

 On Sun, Nov 06, 2011 at 12:30:07AM +0000, David Holland wrote:
  >  -- ; exec lua $(type "$0" | cut -d' ' -f3) "$@"
  >
  > [...]
  >  
  >  Note that "-- 2>/dev/null" still generates a "--: Not found" message
  >  with sh and other shells. To get rid of it, create an executable file
  >  on the path called "--" that does nothing. :-)  (Whether that's viable
  >  or not depends on the environment you're assuming, I guess.)
 
 better way to do that:
 
 XYZZY=--; exec lua $(type "$0" | cut -d' ' -f3) "$@"
 
 Here at least lua accepts "XYZZY=" with no value, but you can also do
 
 XYZZY="zzyzx"--; exec lua $(type "$0" | cut -d' ' -f3) "$@"
 
 -- 
 David A. Holland
 dholland%netbsd.org@localhost
 


Home | Main Index | Thread Index | Old Index