Skip to content

Fix issue with stat format on Linux #698

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

Merged
merged 2 commits into from
Jul 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions module/PowerShellEditorServices/Start-EditorServices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,20 @@ function Set-NamedPipeMode {
[string]
$PipeFile
)

if ($IsWindows) {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wish there was a comment here to explain why this doesn't apply to Windows.

}

chmod $DEFAULT_USER_MODE $PipeFile

if ($IsLinux) {
$mode = stat -c "%A" $PipeFile
$mode = stat -c "%a" $PipeFile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have sworn I tested on linux before shipping this... in any case, my bad and good find.

}
else {
elseif ($IsMacOS) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function gets called only if they're on MacOS or Linux. So the "if Windows" check above and this elseif change isn't really needed. On the other hand, if we wanted to make it more robust, we could keep the Windows check in and remove the MacOS & Linux checks on line 328 and 334.

$mode = stat -f "%A" $PipeFile
}

if ($mode -ne $DEFAULT_USER_MODE) {
ExitWithError "Permissions to the pipe file were not set properly. Expected: $DEFAULT_USER_MODE Actual: $mode for file: $PipeFile"
}
Expand Down