-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix command exists check on Windows with full paths #1850
Conversation
Signed-off-by: username-is-already-taken2 <gary.bright@niu-solutions.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay thank you @username-is-already-taken2 for hacking this at ChefConf 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome improvement @username-is-already-taken2
one more verification for regressions... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While Test-Path looks great at first, the following is not turning green:
cmd = 'C:\Windows\System32\cscript.exe'
describe powershell("If(Test-Path \"#{cmd}\"){exit 0}Else{exit 1}") do
its('exit_status') { should eq 0 }
end
cmd2 = 'cscript.exe'
describe powershell("If(Test-Path \"#{cmd2}\"){exit 0}Else{exit 1}") do
its('exit_status') { should eq 0 }
end
We need to find a solution for all commands without absolute paths
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as detected by Chris :) i think a simple condition should solve this
Signed-off-by: username-is-already-taken2 <gary.bright@niu-solutions.com>
I thought I might have to get funky with an if statement, in the end I swapped out the cmdlet Here is what I used to validate it.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have revised the cmdlet used and updated the pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally and it works great! Thanks again, @username-is-already-taken2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and verified, awesome update @username-is-already-taken2 !! Kudos :)
Amended the
command.rb
file as it wasn't passing the path correctly.Needed to force the return of exit code numbers (rather than $ture $false) to maintain compatiblity with the existing script
chefconf 2017
Fixes #1839