mirror of https://github.com/python/cpython
Optionally honour #! paths in scripts. Fixes #676358.
This commit is contained in:
parent
996acf122d
commit
3d3b74677a
|
@ -2,12 +2,13 @@
|
|||
IBClasses = (
|
||||
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
|
||||
{
|
||||
ACTIONS = {do_apply = id; do_cancel = id; do_reset = id; do_run = id; };
|
||||
ACTIONS = {"do_apply" = id; "do_cancel" = id; "do_reset" = id; "do_run" = id; };
|
||||
CLASS = MyDocument;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
commandline = NSTextField;
|
||||
debug = NSButton;
|
||||
honourhashbang = NSButton;
|
||||
inspect = NSButton;
|
||||
interpreter = NSTextField;
|
||||
nosite = NSButton;
|
||||
|
@ -15,7 +16,7 @@
|
|||
others = NSTextField;
|
||||
tabs = NSButton;
|
||||
verbose = NSButton;
|
||||
with_terminal = NSButton;
|
||||
"with_terminal" = NSButton;
|
||||
};
|
||||
SUPERCLASS = NSDocument;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
|
||||
<plist version="0.9">
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>265 40 356 240 0 0 800 578 </string>
|
||||
<string>551 90 356 240 0 0 1280 1002 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>263.2</string>
|
||||
<string>286.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>5</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5S66</string>
|
||||
<string>6I32</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Binary file not shown.
|
@ -10,6 +10,7 @@
|
|||
|
||||
@protocol FileSettingsSource
|
||||
- (NSString *) interpreter;
|
||||
- (BOOL) honourhashbang;
|
||||
- (BOOL) debug;
|
||||
- (BOOL) verbose;
|
||||
- (BOOL) inspect;
|
||||
|
@ -24,6 +25,7 @@
|
|||
{
|
||||
NSString *interpreter; // The pathname of the interpreter to use
|
||||
NSArray *interpreters; // List of known interpreters
|
||||
BOOL honourhashbang; // #! line overrides interpreter
|
||||
BOOL debug; // -d option: debug parser
|
||||
BOOL verbose; // -v option: verbose import
|
||||
BOOL inspect; // -i option: interactive mode after script
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
if (!self) return self;
|
||||
|
||||
interpreter = [source->interpreter retain];
|
||||
honourhashbang = source->honourhashbang;
|
||||
debug = source->debug;
|
||||
verbose = source->verbose;
|
||||
inspect = source->inspect;
|
||||
|
@ -182,6 +183,7 @@
|
|||
- (void)updateFromSource: (id <FileSettingsSource>)source
|
||||
{
|
||||
interpreter = [[source interpreter] retain];
|
||||
honourhashbang = [source honourhashbang];
|
||||
debug = [source debug];
|
||||
verbose = [source verbose];
|
||||
inspect = [source inspect];
|
||||
|
@ -196,6 +198,7 @@
|
|||
NSUserDefaults *defaults;
|
||||
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
interpreter, @"interpreter",
|
||||
[NSNumber numberWithBool: honourhashbang], @"honourhashbang",
|
||||
[NSNumber numberWithBool: debug], @"debug",
|
||||
[NSNumber numberWithBool: verbose], @"verbose",
|
||||
[NSNumber numberWithBool: inspect], @"inspect",
|
||||
|
@ -216,6 +219,8 @@
|
|||
|
||||
value = [dict objectForKey: @"interpreter"];
|
||||
if (value) interpreter = [value retain];
|
||||
value = [dict objectForKey: @"honourhashbang"];
|
||||
if (value) honourhashbang = [value boolValue];
|
||||
value = [dict objectForKey: @"debug"];
|
||||
if (value) debug = [value boolValue];
|
||||
value = [dict objectForKey: @"verbose"];
|
||||
|
@ -236,9 +241,27 @@
|
|||
|
||||
- (NSString *)commandLineForScript: (NSString *)script
|
||||
{
|
||||
NSString *cur_interp = NULL;
|
||||
char hashbangbuf[1024];
|
||||
FILE *fp;
|
||||
char *p;
|
||||
|
||||
if (honourhashbang &&
|
||||
(fp=fopen([script cString], "r")) &&
|
||||
fgets(hashbangbuf, sizeof(hashbangbuf), fp) &&
|
||||
strncmp(hashbangbuf, "#!", 2) == 0 &&
|
||||
(p=strchr(hashbangbuf, '\n'))) {
|
||||
*p = '\0';
|
||||
p = hashbangbuf + 2;
|
||||
while (*p == ' ') p++;
|
||||
cur_interp = [NSString stringWithCString: p];
|
||||
}
|
||||
if (!cur_interp)
|
||||
cur_interp = interpreter;
|
||||
|
||||
return [NSString stringWithFormat:
|
||||
@"\"%@\"%s%s%s%s%s%s %@ \"%@\" %s",
|
||||
interpreter,
|
||||
cur_interp,
|
||||
debug?" -d":"",
|
||||
verbose?" -v":"",
|
||||
inspect?" -i":"",
|
||||
|
@ -254,6 +277,7 @@
|
|||
|
||||
// FileSettingsSource protocol
|
||||
- (NSString *) interpreter { return interpreter;};
|
||||
- (BOOL) honourhashbang { return honourhashbang; };
|
||||
- (BOOL) debug { return debug;};
|
||||
- (BOOL) verbose { return verbose;};
|
||||
- (BOOL) inspect { return inspect;};
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
@interface MyDocument : NSDocument <FileSettingsSource>
|
||||
{
|
||||
IBOutlet NSTextField *interpreter;
|
||||
IBOutlet NSButton *honourhashbang;
|
||||
IBOutlet NSButton *debug;
|
||||
IBOutlet NSButton *verbose;
|
||||
IBOutlet NSButton *inspect;
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
// [[self window] setTitle: script];
|
||||
|
||||
[interpreter setStringValue: [settings interpreter]];
|
||||
[honourhashbang setState: [settings honourhashbang]];
|
||||
[debug setState: [settings debug]];
|
||||
[verbose setState: [settings verbose]];
|
||||
[inspect setState: [settings inspect]];
|
||||
|
@ -152,6 +153,7 @@
|
|||
|
||||
// FileSettingsSource protocol
|
||||
- (NSString *) interpreter { return [interpreter stringValue];};
|
||||
- (BOOL) honourhashbang { return [honourhashbang state];};
|
||||
- (BOOL) debug { return [debug state];};
|
||||
- (BOOL) verbose { return [verbose state];};
|
||||
- (BOOL) inspect { return [inspect state];};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
commandline = NSTextField;
|
||||
debug = NSButton;
|
||||
filetype = NSPopUpButton;
|
||||
honourhashbang = NSButton;
|
||||
inspect = NSButton;
|
||||
interpreter = NSTextField;
|
||||
nosite = NSButton;
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>126 59 356 240 0 0 1024 746 </string>
|
||||
<string>660 84 519 534 0 0 1280 1002 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>291.0</string>
|
||||
<string>286.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>5</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>6G30</string>
|
||||
<string>6I32</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Binary file not shown.
|
@ -8,6 +8,7 @@
|
|||
{
|
||||
IBOutlet NSPopUpButton *filetype;
|
||||
IBOutlet NSTextField *interpreter;
|
||||
IBOutlet NSButton *honourhashbang;
|
||||
IBOutlet NSButton *debug;
|
||||
IBOutlet NSButton *verbose;
|
||||
IBOutlet NSButton *inspect;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
// [[self window] setTitle: script];
|
||||
|
||||
[interpreter setStringValue: [settings interpreter]];
|
||||
[honourhashbang setState: [settings honourhashbang]];
|
||||
[debug setState: [settings debug]];
|
||||
[verbose setState: [settings verbose]];
|
||||
[inspect setState: [settings inspect]];
|
||||
|
@ -74,6 +75,7 @@
|
|||
|
||||
// FileSettingsSource protocol
|
||||
- (NSString *) interpreter { return [interpreter stringValue];};
|
||||
- (BOOL) honourhashbang { return [honourhashbang state]; };
|
||||
- (BOOL) debug { return [debug state];};
|
||||
- (BOOL) verbose { return [verbose state];};
|
||||
- (BOOL) inspect { return [inspect state];};
|
||||
|
|
|
@ -132,7 +132,6 @@
|
|||
4A9504D0FFE6A4CB11CA0CBA,
|
||||
4A9504D1FFE6A4CB11CA0CBA,
|
||||
);
|
||||
hasScannedForEncodings = 1;
|
||||
isa = PBXProject;
|
||||
mainGroup = 2A37F4AAFDCFA73011CA2CEA;
|
||||
projectDirPath = "";
|
||||
|
@ -404,6 +403,7 @@
|
|||
</dict>
|
||||
</plist>
|
||||
";
|
||||
shouldUseHeadermap = 0;
|
||||
};
|
||||
2A37F4C7FDCFA73011CA2CEA = {
|
||||
buildActionMask = 2147483647;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<string>/usr/bin/pythonw</string>
|
||||
<string>/Applications/MacPython-OSX/python-additions/Python.app/Contents/MacOS/python</string>
|
||||
</array>
|
||||
<key>honourhashbang</key>
|
||||
<false/>
|
||||
<key>nosite</key>
|
||||
<false/>
|
||||
<key>optimize</key>
|
||||
|
@ -45,7 +47,9 @@
|
|||
<string>/usr/bin/pythonw</string>
|
||||
<string>/Applications/MacPython-OSX/python-additions/Python.app/Contents/MacOS/python</string>
|
||||
</array>
|
||||
<key>nosite</key>
|
||||
<key>honourhashbang</key>
|
||||
<false/>
|
||||
<key>nosite</key>
|
||||
<false/>
|
||||
<key>optimize</key>
|
||||
<false/>
|
||||
|
@ -69,7 +73,9 @@
|
|||
<string>/Library/Frameworks/Python.framework/Versions/Current/bin/python</string>
|
||||
<string>/usr/bin/python</string>
|
||||
</array>
|
||||
<key>nosite</key>
|
||||
<key>honourhashbang</key>
|
||||
<false/>
|
||||
<key>nosite</key>
|
||||
<false/>
|
||||
<key>optimize</key>
|
||||
<false/>
|
||||
|
|
Loading…
Reference in New Issue