GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add validation that Invoke-Item opens directory in Finder on Mac · Issue #4282 · PowerShell/PowerShell

Add validation that Invoke-Item opens directory in Finder on Mac #4282

Copy link
Copy link
Closed
Closed
Add validation that Invoke-Item opens directory in Finder on Mac#4282
Copy link
Labels
OS-macOSResolution-FixedThe issue is fixed.The issue is fixed.WG-Quality-Testissues in a test or in test infrastructureissues in a test or in test infrastructure

Description

@SteveL-MSFT
Steve Lee (SteveL-MSFT)
opened on Jul 18, 2017
Issue body actions

For PR #4262 validation was added to Windows and Linux.
On Linux, we change the default application to a shell command to verify the output. On Mac, you would
use lsregister to do something similar, however, MacOS doesn't have a straightforward way to register
and unregister at runtime (no api). Registration is done as part of app creation and startup.

Activity

  1. Steve Lee (SteveL-MSFT)
    added
    WG-Quality-Testissues in a test or in test infrastructureissues in a test or in test infrastructure
    OS-macOS
    on Jul 18, 2017
  2. mklement0 commented on Jul 18, 2017

    @mklement0
    Michael Klement (mklement0)
    on Jul 18, 2017
    Contributor
    More actions

    You can use AppleScript as follows (via its osascript CLI):

    $appleScriptWindowCount = 'tell application "Finder" to count of windows'
    
    $before = [int] ($appleScriptWindowCount | osascript)
    
    Invoke-Item $PSHome
    
    $startTime = Get-Date
    while (((Get-Date) - $startTime).TotalSeconds -lt 5 -and ([int] ($appleScriptWindowCount | osascript) -eq $before))
    {
      Start-Sleep -Milliseconds 100
    }
    
    $after = [int] ($appleScriptWindowCount | osascript)
    
    $before + 1  | Should Be $after
    
    ('tell application "Finder" to POSIX path of ((target of front window) as text)' | osascript) | Should Be "$PSHOME/"
    
    'tell application "Finder" to close front window' | osascript

    Note the need to pipe the AppleScript source code to osascript, because argument passing on Unix is still horribly broken (I've lost track of the debate):

    osascript -e 'tell application "Finder" to count of windows'

    SHOULD work, but currently doesn't, because the embedded " are discarded.

    Remember: On Unix, no funny quoting business (no rebuilding of the command line) is needed nor should it be attempted after PowerShell has parsed a command line; the resulting values should be passed as literals, as part of an argument array to the target utility.

    Reacted by Steve Lee
  3. SteveL-MSFT commented on Jul 25, 2017

    @SteveL-MSFT
    Steve Lee (SteveL-MSFT)
    on Jul 25, 2017
    MemberAuthor
    More actions

    Michael Klement (@mklement0) got around to finishing this. your pointer to AppleScript really helped!

    Reacted by Michael Klement
  4. mklement0 commented on Jul 26, 2017

    @mklement0
    Michael Klement (mklement0)
    on Jul 26, 2017
    Contributor
    More actions

    Steve Lee (@SteveL-MSFT): I am glad to hear it.

    Ceterum censeo argumentum transitum esse reficiendam.[1]

    [1] That's fake Latin for: Fix the argument passing on Unix platforms.

  5. SteveL-MSFT commented on Jul 26, 2017

    @SteveL-MSFT
    Steve Lee (SteveL-MSFT)
    on Jul 26, 2017
    MemberAuthor
    More actions

    If there isn't an issue already, please open one for that

  6. Dongbo Wang (daxian-dbw)
    closed this as completedin #4262on Jul 28, 2017
  7. Ilya (iSazonov)
    added
    Resolution-FixedThe issue is fixed.The issue is fixed.
    on Jul 28, 2017
  8. mklement0 commented on Aug 28, 2017

    @mklement0
    Michael Klement (mklement0)
    on Aug 28, 2017
    Contributor
    More actions

    Steve Lee (@SteveL-MSFT): Please have a look at #1995 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-macOSResolution-FixedThe issue is fixed.The issue is fixed.WG-Quality-Testissues in a test or in test infrastructureissues in a test or in test infrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.