Skip to content

Get-Help removing space on first code line in examples #14656

Closed

Description

Steps to reproduce

Have a function with example formatted as such:

    .EXAMPLE
    PS> $session = New-TssSession -SecretServer https://alpha -Credential $ssCred
    PS> Disable-TssSecret -TssSession $session -Id 93

    Disables secret 93

Import the module and running Get-Help Disable-TssSecret -Examples is removing the space on the first code line:

image

Expected behavior

The output of the example to match that coded in function.

Actual behavior

Space is removed on the first line of code, not matching the example as coded.

Environment data


Name                           Value
----                           -----
PSVersion                      7.1.1
PSEdition                      Core
GitCommitId                    7.1.1
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


Note I did find it does this in Windows PowerShell as well.

Activity

  1. added
    Issue-Question
    on Jan 23, 2021
  2. mklement0 commented on Jan 23, 2021

    @mklement0
    Contributor

    The behavior is definitely undesirable, but let me point out that you needn't provide a prompt string explicitly at all:
    If the first line - only - doesn't have a prefix that ends with >, prefix PS > (sic) is automatically prepended.

    If there is a prefix that ends with >, as in your case, any whitespace that follows it is unexpectedly stripped - that is the bug.

    I think two fixes are called for:

    • The default prefix should be PS> , not PS > , to be consistent with existing cmdlet help - PR Fix for #6938 Fixed prompt string to be platform agnostic in examples #7255 made the prefix platform-agnostic, but introduced the undesirable space before >.

    • An existing prefix with > should be left alone, but only if it starts with PS; otherwise, an unprefixed example command that happens to use > as the redirection operator (e.g., foo > bar.txt) would unexpectedly not receive the default prefix.

  3. wsmelton commented on Jan 23, 2021

    @wsmelton
    Author

    but let me point out that you needn't provide a prompt string explicitly at all

    Yeah, but this just looks wrong when you are viewing it from the code on GitHub:

        .EXAMPLE
        $session = New-TssSession -SecretServer https://alpha -Credential $ssCred
        PS> Disable-TssSecret -TssSession $session -Id 93
    
        Disables secret 93
    

    It also causes this to happen when the module is used in Windows PowerShell (prepending the wrong prompt):

    image

    If that was consistent through both then I'd agree, but since it is not we have no choice but to always include it.

  4. added
    WG-Interactive-HelpSystem
    on Jan 24, 2021
  5. iSazonov commented on Jan 24, 2021

    @iSazonov
    Collaborator

    It seems to be more convenient if this code was copyable and executable - remove "PS>" prefix and add "#" before text.

  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  7. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  8. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  9. added
    Resolution-No Activity
    on Nov 16, 2023
  10. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

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

    Issue-QuestionResolution-No ActivityWG-Interactive-HelpSystem

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions