Skip to content
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 issue with stat format on Linux #698

Merged
merged 2 commits into from
Jul 11, 2018

Conversation

rjmholt
Copy link
Contributor

@rjmholt rjmholt commented Jul 11, 2018

The stat usage in the startup script currently does not work on Linux.

This changes the %A to %a to make it work.

@@ -224,7 +224,7 @@ function Set-NamedPipeMode {
)
chmod $DEFAULT_USER_MODE $PipeFile
if ($IsLinux) {
$mode = stat -c "%A" $PipeFile
$mode = stat -c "%a" $PipeFile
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of my depth here but I assume we know that %A works on macOS? Also does the else below execute on Windows? Or maybe we don't call this function at all on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tylerl0706 almost certainly wrote and tested the script on macOS, so I'm assuming that works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stat -f "%a" on macOS gives me something totally different

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stat -f "%A" gives me e.g. 700

Copy link
Contributor

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

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

LGTM

@rjmholt rjmholt merged commit eecfe02 into PowerShell:master Jul 11, 2018
Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

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

Never got the chance to review this because of the cruise but I had a couple comments.

@@ -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.

}
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.

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.

@rjmholt rjmholt deleted the fix-stat-linux-format branch December 12, 2018 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants