You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add validation that Invoke-Item opens directory in Finder on Mac #4282
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.
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-Datewhile (((Get-Date) -$startTime).TotalSeconds -lt5-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.
Activity
mklement0 commentedon Jul 18, 2017
You can use AppleScript as follows (via its
osascriptCLI):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):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.
SteveL-MSFT commentedon Jul 25, 2017
Michael Klement (@mklement0) got around to finishing this. your pointer to AppleScript really helped!
mklement0 commentedon Jul 26, 2017
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.
SteveL-MSFT commentedon Jul 26, 2017
If there isn't an issue already, please open one for that
mklement0 commentedon Aug 28, 2017
Steve Lee (@SteveL-MSFT): Please have a look at #1995 (comment).