Skip to content

PowerShell: Expand Alias command doesn't work on macOS #1185

Closed
@TylerLeonhardt

Description

@TylerLeonhardt

Issue Description

PowerShell: Expand Alias command doesn't work on macOS. The Integrated Console reacts to the command by showing a new prompt.

Attached are the logs.

This looks to be the important bit:

2/2/18 9:15:57 AM [VERBOSE] - Method "ExecuteCommand" at line 491 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Session\PowerShellContext.cs

    Attempting to execute command(s):
    
    
    function __Expand-Alias {
    
        param($targetScript)
    
        [ref]$errors=$null
    
        $tokens = [System.Management.Automation.PsParser]::Tokenize($targetScript, $errors).Where({$_.type -eq 'command'}) |
                        Sort Start -Descending
    
        foreach ($token in  $tokens) {
            $definition=(Get-Command ('`'+$token.Content) -CommandType Alias -ErrorAction SilentlyContinue).Definition
    
            if($definition) {
                $lhs=$targetScript.Substring(0, $token.Start)
                $rhs=$targetScript.Substring($token.Start + $token.Length)
    
                $targetScript=$lhs + $definition + $rhs
           }
        }
    
        $targetScript
    }
    

2/2/18 9:15:57 AM [VERBOSE] - Method "OnSessionStateChanged" at line 1138 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Session\PowerShellContext.cs

    Session state changed --
    
        Old state: Ready
        New state: Running
        Result: NotFinished

2/2/18 9:15:57 AM [VERBOSE] - Method "OnSessionStateChanged" at line 1138 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Session\PowerShellContext.cs

    Session state changed --
    
        Old state: Running
        New state: Ready
        Result: Completed

2/2/18 9:15:57 AM [ERROR] - Method "ExecuteCommand" at line 545 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Session\PowerShellContext.cs

    Execution completed with errors:
    
    The term 'Sort' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    The term 'Sort' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    The term 'Sort' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    The term 'Sort' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    The term 'Sort' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Just not sure why that error would get thrown.

Attached Logs

logs.zip

Environment Information

Visual Studio Code

Name Version
Operating System Darwin x64 16.7.0
VSCode 1.20.0-insider
PowerShell Extension Version 1.5.1

PowerShell Information

Name Value
PSVersion 6.0.0-rc.2
PSEdition Core
GitCommitId v6.0.0-rc.2
OS Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018, root:xnu-3789.73.8~1/RELEASE_X86_64
Platform Unix
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.10032.0 6.0.0-rc.2
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
beautify HookyQR 1.3.0
code-settings-sync Shan 2.8.7
color-highlight naumovs 2.3.0
csharp ms-vscode 1.13.1
docthis joelday 0.6.0
ExtensionUpdateCheck HookyQR 0.0.2
ftp-simple humy2833 0.5.8
hipsum third774 1.0.7
indent-rainbow oderwat 0.7.2
indent4to2 Compulim 0.1.2
path-intellisense christian-kohler 1.4.2
PowerShell ms-vscode 1.5.1
puppypopup StineTheBean 0.0.2
slack sozercan 0.0.14
Theme-azure gerane 0.0.2
Theme-BetterJS gerane 0.0.3
theme-monokai-dark-soda AdamCaviness 0.0.5
theme-monoko smdl 0.0.1
theme-railgun be5invis 2.3.0
theme-toothpaste aalaap 0.0.1
Theme-Zenburn gerane 0.0.3
trailing-spaces shardulm94 0.2.11
tslint eg2 1.0.24
vscode-dash deerawan 1.8.0
vscode-docker PeterJausovec 0.0.23
vscode-file-peek abierbaum 1.0.1
vscode-icons robertohuertasm 7.19.0
vscode-markdownlint DavidAnson 0.13.0
vscode-npm-script eg2 0.3.3
vscode-svgviewer cssho 1.4.3
word-count hypnoes 0.1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions