Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Fix Regression In #12317 For zsh and Patch Environment On OSX For Users Of fish - #12396

Merged
maxbrunsfeld merged 4 commits into
masterfrom
jf-fix-zsh-launch-from-dock-regression
Aug 11, 2016
Merged

maxbrunsfeld merged 4 commits into
masterfrom
jf-fix-zsh-launch-from-dock-regression

Conversation

@joefitzgerald

Copy link
Copy Markdown
Contributor

In Atom 1.7 and 1.8, the environment would be patched for users of the zsh shell on OS X, who launched Atom from the Dock / Finder / Spotlight. A whitelist of shells was established in #12317, which is extended here to include zsh and fish.

Tested with built-in zsh, homebrew installed zsh, and homebrew installed fish.

In Atom 1.7 and 1.8, the environment would be patched for users of the zsh shell on OS X. A whitelist of shells was established in #12317, which is extended here.
@joefitzgerald joefitzgerald changed the title Fix Regression In #12317 For zsh Fix Regression In #12317 For zsh and Patch Environment On OSX For Users Of fish Aug 11, 2016
@joefitzgerald joefitzgerald changed the title Fix Regression In #12317 For zsh and Patch Environment On OSX For Users Of fish 🐛 Fix Regression In #12317 For zsh and Patch Environment On OSX For Users Of fish Aug 11, 2016
@joefitzgerald joefitzgerald changed the title 🐛 Fix Regression In #12317 For zsh and Patch Environment On OSX For Users Of fish Fix Regression In #12317 For zsh and Patch Environment On OSX For Users Of fish Aug 11, 2016
Comment thread src/update-process-env.js
}

return false
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would suggest two fairly minor stylistic changes to this shellShouldBePatched function:

  1. I think it should take a shell as an argument and return a boolean, rather than internally getting the shell from process.env and returning either a string or null.
  2. I think the name is a bit odd; it makes it sound like the shell itself is getting patched. Maybe canGetLoginEnvFromShell(shellPath)?

I think this would make the function a little simpler to test, since you wouldn't have to overwrite process.env.SHELL. You wouldn't need a loop; you could just do:

expect(canGetLoginEnvFromShell('/bin/bash')).toBe(true)
expect(canGetLoginEnvFromShell('/some/other/bash')).toBe(true)
expect(canGetLoginEnvFromShell('/usr/local/bin/fish')).toBe(true)

expect(canGetLoginEnvFromShell('/bin/give-me-cash')).toBe(false)
expect(canGetLoginEnvFromShell('/usr/bin/birthday-bash')).toBe(false)

* shellShouldBePatched > envShouldBePatched
Comment thread spec/update-process-env-spec.js Outdated
})

describe('shells on osx', function () {
it('envShouldBePatched() returns the shell when the shell should be patched', function () {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you move the function name up into the describe, so that the it sentences read a bit better?

describe('envShouldBePatched()', function () {
  it('returns true for shells that ', function () {
    // ...
  })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The envShouldBePatched name is a little clearer, but I think it'd be best to make it clear that the return value depends on the shell, not the env. Also, the env is completely replaced (except for the 3 'special' variables), so emphasizing the 'patching' doesn't seem entirely necessary.

How about shouldGetEnvFromShell?

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

Great; Thanks for fixing this regression @joefitzgerald!

@maxbrunsfeld
maxbrunsfeld merged commit b060fa6 into master Aug 11, 2016
@maxbrunsfeld
maxbrunsfeld deleted the jf-fix-zsh-launch-from-dock-regression branch August 11, 2016 23:17
maxbrunsfeld pushed a commit that referenced this pull request Aug 16, 2016
…ssion

Fix Regression In #12317 For zsh and Patch Environment On OSX For Users Of fish
maxbrunsfeld pushed a commit that referenced this pull request Aug 16, 2016
…ssion

Fix Regression In #12317 For zsh and Patch Environment On OSX For Users Of fish
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants