#DOCUMENTATION by cg
class: Win32OperatingSystem class
comment/format in: #commandAndArgsForOSCommand:
--- a/Win32OperatingSystem.st Wed Nov 27 17:24:43 2019 +0100
+++ b/Win32OperatingSystem.st Wed Nov 27 19:50:37 2019 +0100
@@ -3754,8 +3754,8 @@
|shell args wDir cmdName path commandString|
aCommandString isNonByteCollection ifTrue:[
- "easy: the caller does not want a shell to be executed"
- ^ Array with:aCommandString first with:(aCommandString asStringWith:' ') with:nil.
+ "easy: the caller does not want a shell to be executed"
+ ^ Array with:aCommandString first with:(aCommandString asStringWith:' ') with:nil.
].
"/
@@ -3781,57 +3781,57 @@
cmdName := (aCommandString ? '') withoutSeparators.
(cmdName isEmpty or:[cmdName includesAny:'<>|&']) ifFalse:[
- "/ test whether the command is a plain executable;
- "/ if so, no shell is required
- |index file suffix|
-
- cmdName first = $" ifTrue:[
- index := cmdName indexOf:$" startingAt:2.
- ] ifFalse:[
- index := 1.
- ].
- index := cmdName indexOfSeparatorStartingAt:index.
- index ~~ 0 ifTrue:[
- cmdName := cmdName copyFrom:1 to:(index-1).
- args := cmdName copyFrom:(index+1).
- ] ifFalse:[
- args := ''.
- ].
-
- (cmdName first = $" and:[cmdName last = $"]) ifTrue:[
- cmdName := (cmdName copyFrom:2 to:cmdName size - 1) withoutSeparators.
- ].
- file := cmdName asFilename.
- file suffix isEmpty ifTrue:[
- file := file withSuffix:'exe'.
- ].
- path := file fullAlternativePathName.
- (OperatingSystem getBinaryType:path) notNil ifTrue:[
- "/ is an executable, no shell required
- ^ Array with:path with:aCommandString with:nil.
+ "/ test whether the command is a plain executable;
+ "/ if so, no shell is required
+ |index file suffix|
+
+ cmdName first = $" ifTrue:[
+ index := cmdName indexOf:$" startingAt:2.
+ ] ifFalse:[
+ index := 1.
+ ].
+ index := cmdName indexOfSeparatorStartingAt:index.
+ index ~~ 0 ifTrue:[
+ cmdName := cmdName copyFrom:1 to:(index-1).
+ args := cmdName copyFrom:(index+1).
+ ] ifFalse:[
+ args := ''.
+ ].
+
+ (cmdName first = $" and:[cmdName last = $"]) ifTrue:[
+ cmdName := (cmdName copyFrom:2 to:cmdName size - 1) withoutSeparators.
+ ].
+ file := cmdName asFilename.
+ file suffix isEmpty ifTrue:[
+ file := file withSuffix:'exe'.
+ ].
+ path := file fullAlternativePathName.
+ (OperatingSystem getBinaryType:path) notNil ifTrue:[
+ "/ is an executable, no shell required
+ ^ Array with:path with:aCommandString with:nil.
"/ ^ Array with:path with:(path, ' ', args).
- ].
- path := self pathOfCommand:cmdName.
- (path notNil and:[(OperatingSystem getBinaryType:path) notNil]) ifTrue:[
- "/ is an executable, no shell required
- ^ Array with:path with:aCommandString with:nil.
+ ].
+ path := self pathOfCommand:cmdName.
+ (path notNil and:[(OperatingSystem getBinaryType:path) notNil]) ifTrue:[
+ "/ is an executable, no shell required
+ ^ Array with:path with:aCommandString with:nil.
"/ ^ Array with:path with:(path, ' ', args).
- ].
+ ].
].
shell := self getEnvironment:'COMSPEC'.
shell isNil ifTrue:[
- wDir := self getWindowsSystemDirectory asFilename.
- shell := #('cmd.exe' 'command.com') detect:[:eachCommand|
- (wDir / eachCommand) isExecutableProgram
- ] ifNone:[
- self error:'no cmd.exe available'.
- ].
- shell := (wDir / shell) pathName.
+ wDir := self getWindowsSystemDirectory asFilename.
+ shell := #('cmd.exe' 'command.com') detect:[:eachCommand|
+ (wDir / eachCommand) isExecutableProgram
+ ] ifNone:[
+ self error:'no cmd.exe available'.
+ ].
+ shell := (wDir / shell) pathName.
].
cmdName isEmpty ifTrue:[
- ^ Array with:shell with:'' with:nil.
+ ^ Array with:shell with:'' with:nil.
].
commandString := aCommandString.
@@ -3845,6 +3845,7 @@
"
self commandAndArgsForOSCommand:''
self commandAndArgsForOSCommand:'%ProgramFiles%\notepad++\notepad++.exe'
+ self commandAndArgsForOSCommand:'%ProgramFiles(x86)%\notepad++\notepad++.exe'
self commandAndArgsForOSCommand:'diff'
self commandAndArgsForOSCommand:'diff.exe'
self commandAndArgsForOSCommand:'dir/w'