--- a/UnixOperatingSystem.st Thu Mar 28 16:00:29 2019 +0100
+++ b/UnixOperatingSystem.st Thu Mar 28 16:01:15 2019 +0100
@@ -3705,48 +3705,45 @@
Return nil if aCommand is either absolute, or relative and not executable,
or not executable is found along the PATH."
- |path f fExt commandFilename|
+ |path f fExt commandFilename exeExtensions|
commandFilename := aCommand asFilename.
commandFilename isAbsolute ifTrue:[
- "/ something like "/foo/...", tried path is it
- commandFilename isExecutable ifFalse:[^ nil].
- ^ commandFilename pathName
+ "/ something like "/foo/...", tried path is it
+ commandFilename isExecutable ifFalse:[^ nil].
+ ^ commandFilename pathName
].
commandFilename isExplicitRelative ifTrue:[
- "/ something like "../foo/...", tried path resolved relative to the current directory
- commandFilename isExecutable ifFalse:[^ nil].
- ^ commandFilename pathName
+ "/ something like "../foo/...", tried path resolved relative to the current directory
+ commandFilename isExecutable ifFalse:[^ nil].
+ ^ commandFilename pathName
].
(aCommand includes:$/) ifTrue:[
- "/ something like "smalltalk/stx", tried path is relative to the current directory
- (f := ('./',aCommand) asFilename) isExecutable ifTrue:[
- ^ f pathName
- ].
- ^ nil
+ "/ something like "smalltalk/stx", tried path is relative to the current directory
+ (f := ('./',aCommand) asFilename) isExecutable ifTrue:[
+ ^ f pathName
+ ].
+ ^ nil
].
"/ command is a single word, not relative and not absolute.
"/ search along PATH environment variable to see what a shell would do.
+ exeExtensions := self executableFileExtensions.
path := self getEnvironment:'PATH'.
path notEmptyOrNil ifTrue:[
- (path asCollectionOfSubstringsSeparatedBy:self pathSeparator) do:[:eachPathComponent |
- eachPathComponent isEmpty ifTrue:[
- f := commandFilename
- ] ifFalse:[
- f := eachPathComponent asFilename construct:aCommand.
- ].
- self executableFileExtensions do:[:eachExtension |
- eachExtension notEmpty ifTrue:[
- fExt := f addSuffix:eachExtension.
- ] ifFalse:[
- fExt := f.
- ].
- fExt isExecutable ifTrue:[
- ^ fExt pathName
- ].
- ].
- ].
+ (path asCollectionOfSubstringsSeparatedBy:self pathSeparator) do:[:eachPathComponent |
+ eachPathComponent isEmpty ifTrue:[
+ f := commandFilename
+ ] ifFalse:[
+ f := eachPathComponent asFilename construct:aCommand.
+ ].
+ exeExtensions do:[:eachExtension |
+ fExt := f addSuffix:eachExtension.
+ fExt isExecutable ifTrue:[
+ ^ fExt pathName
+ ].
+ ].
+ ].
].
^ nil