Skip to content

Indicate version of shell requesting completions #689

@rgoldberg

Description

@rgoldberg

A SAP_SHELL_VERSION environment variable should be exported by each generated shell completion script.

Its value will be the version of the shell requesting completions. e.g., bash could be 3.2.57, 5.2.37, etc.; zsh could be 5.3, 5.9, etc.; fish could be 3.7.1`, etc.

It will only be available at completion time, not at script-generation time, so it will only be useful for shellCommand or custom CompletionKinds. shellCommand is written to the script at generation time, but the commands in its String argument can use ${SAP_SHELL_VERSION}, while the function argument for custom is run during completion, so ${SAP_SHELL_VERSION} will be used to set the following while while a custom completion function is running (otherwise, it will be set to nil):

public struct CompletionShell:  {
  
  public internal(set) static var requestingVersion: String?
  
}

This will allow custom completions to provide better completions (older shell versions might not support newer completion formats / shell commands or builtins), and will also allow them to know when they will receive different data due to shell bugs / limitations limited to certain shell versions (e.g., various issues in the fish commandline command will be fixed in the forthcoming fish 4.0.0, so output will be different for 4.0.0+ & prior versions).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions