From: <pj...@us...> - 2009-04-11 00:25:30
|
Revision: 6213 http://jython.svn.sourceforge.net/jython/?rev=6213&view=rev Author: pjenvey Date: 2009-04-11 00:25:21 +0000 (Sat, 11 Apr 2009) Log Message: ----------- o reapply test_cmd_line workaround o fix error handling of bad -c/-m command lines Modified Paths: -------------- trunk/jython/Lib/test/test_cmd_line.py trunk/jython/src/org/python/util/jython.java trunk/jython/src/shell/jython Modified: trunk/jython/Lib/test/test_cmd_line.py =================================================================== --- trunk/jython/Lib/test/test_cmd_line.py 2009-04-11 00:24:56 UTC (rev 6212) +++ trunk/jython/Lib/test/test_cmd_line.py 2009-04-11 00:25:21 UTC (rev 6213) @@ -50,7 +50,8 @@ self.assertTrue('usage' in self.start_python('-h')) def test_version(self): - version = 'Python %d.%d' % sys.version_info[:2] + prefix = 'J' if test.test_support.is_jython else 'P' + version = prefix + 'ython %d.%d' % sys.version_info[:2] self.assertTrue(self.start_python('-V').startswith(version)) def test_run_module(self): Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2009-04-11 00:24:56 UTC (rev 6212) +++ trunk/jython/src/org/python/util/jython.java 2009-04-11 00:25:21 UTC (rev 6213) @@ -259,6 +259,7 @@ interp.exec(opts.command); } catch (Throwable t) { Py.printException(t); + System.exit(1); } } @@ -273,7 +274,7 @@ } catch (Throwable t) { Py.printException(t); interp.cleanup(); - System.exit(0); + System.exit(-1); } } } @@ -407,8 +408,20 @@ Options.importSite = false; } else if (arg.equals("-c")) { - command = args[++index]; - if (!fixInteractive) interactive = false; + if (arg.length() > 2) { + command = arg.substring(2); + } + else if ((index + 1) < args.length) { + command = args[++index]; + } else { + System.err.println("Argument expected for the -c option"); + System.err.print(jython.usageHeader); + System.err.println("Try `jython -h' for more information."); + return false; + } + if (!fixInteractive) { + interactive = false; + } index++; break; } Modified: trunk/jython/src/shell/jython =================================================================== --- trunk/jython/src/shell/jython 2009-04-11 00:24:56 UTC (rev 6212) +++ trunk/jython/src/shell/jython 2009-04-11 00:25:21 UTC (rev 6213) @@ -117,9 +117,13 @@ fi ;; # Match switches that take an argument - -c|-C|-jar|-Q|-W) - python_args=("${python_args[@]}" "$1" "$2") - shift + -c|-C|-m|-jar|-Q|-W) + if [ $# = 1 ]; then + python_args=("${python_args[@]}" "$1") + else + python_args=("${python_args[@]}" "$1" "$2") + shift + fi; ;; # Match -Dprop=val type args -D*) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |