-
Notifications
You must be signed in to change notification settings - Fork 325
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
(maint) quote file path in file_contents_on
and file_exists_on
#1647
Closed
ciprianbadescu
wants to merge
2
commits into
voxpupuli:master
from
ciprianbadescu:maint/fix-log-file-checks-on-windows
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -492,12 +492,12 @@ def win_ads_path(file_path) | |
# @return [Boolean] Whether the file exists on the host (using `test -f`) | ||
def file_exists_on(host, file_path) | ||
if host['platform'] =~ /windows/ | ||
command = %(Test-Path #{file_path}) | ||
command = %(Test-Path "#{file_path}") | ||
|
||
if file_path.include?(':') | ||
split_path = win_ads_path(file_path) | ||
|
||
command = %(Test-Path #{split_path[:path]}) | ||
command = %(Test-Path "#{split_path[:path]}") | ||
command += %( -AND Get-Item -path #{split_path[:path]} -stream #{split_path[:ads]}) if split_path[:ads] | ||
end | ||
|
||
|
@@ -555,8 +555,8 @@ def file_contents_on(host, file_path) | |
if host['platform'] =~ /windows/ | ||
file_path.gsub!('/', '\\') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that substitution is not done in file_exists_on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks to work without, should I still add it there? |
||
|
||
command = %{Get-Content -Raw -Path #{file_path}} | ||
command += %{ -Stream #{split_path[:ads]}} if split_path[:ads] | ||
command = %{Get-Content -Raw -Path "#{file_path}"} | ||
command += %{ -Stream "#{split_path[:ads]}"} if split_path[:ads] | ||
|
||
file_contents = on(host, powershell(command))&.stdout&.strip | ||
else | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this to support paths with spaces in them?
I think you would need it here too and on line 495 above for the case where there is no ads path?
https://github.com/puppetlabs/beaker/pull/1647/files#diff-cdd2e965e7b543eb19634118d43851b8R495
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.
It is to protect windows path (c:\asdasd) from cygwin shell expansion. Without it
C:\Windows\TEMP\install-puppet-2020-05-15_15.38.14.log
gets modified toC:\cygwin64\home\Administrator\WindowsTEMPinstall-puppet-2020-05-15_15.38.14.log