Nmap Development mailing list archives

Re: Ndiff included in Windows zip distribution


From: David Fifield <david () bamsoftware com>
Date: Thu, 5 Feb 2009 02:03:04 +0100

On Wed, Feb 04, 2009 at 06:37:11PM -0600, Tom Sellers wrote:
Here are my thoughts, untested of unfortunately.  My windows boxen are not
handy at the moment.

It looks like you are not really modifying the PATH variable, just combining
it will potential path variables in order to search for python.exe.  What I would
do in this case is change the "set PATH=%PATH%..." line to "set SEARCHPATH=%PATH..."

Using SEARCHPATH, or any other unused variable name of your choice, avoids the
need for using setlocal/endlocal to protect the environment's PATH variable.

Thanks for the suggestion. I tried it, but it turns out that it pollutes
the environment outside the batch file; i.e., after you run ndiff.bat
the environment variable SEARCHPATH is set in the shell.

This will allow either the python return code to carry through past the end of
the batch execution or let you save the python script return code and then use
it to set ERRORLEVEL upon batch exit.

I considered setting ERRORLEVEL, but I don't think that's the right way.
Having an environment variable called ERRORLEVEL removes the magic
behavior of the pseudo-variable ERRORLEVEL for the rest of the session:
http://batcheero.blogspot.com/2007/07/never-set-errorlevel.html

I am  surprised that the python installation process does not set a Windows
environmental variable containing the path to its folder or .exe.

Even if it did do that, it wouldn't help those who don't have Python
installed. Part of the idea of using the batch file was that if someone
runs "ndiff" without having Python installed, they get an error message
telling them what they need to do.

Would it be better long term to rename the python script to ndiff.py?
I know it would be a pain short term, but would remove the need
to use and maintain batches in the future.

I don't like breaking the abstraction of an executable just to ease a
minor Windows compatibility issue. Also with the py2exe build it would
lead to the strange name ndiff.py.exe.

David Fifield

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: