Skip to content

implement string unescape to complement string escape #3543

Closed

Description

@kbauer

The command string escape allows bypassing limitations of the scripting language where needed, e.g. to store a list in a single string (allowing, but discouraging, nested list semantics) with

set var (printf "%s " (string escape $PATH))

As of 2.4.0, however, there is no safe way to unescape such values. While

set list_var (eval "printf '%s\n' $var")

unpacks the quoted list into an actual list, but will happily evaluate any commands smuggled into a manipulated $var as well. A string unescape subcommand would fix this.


  • Have you checked if problem occurs with fish 2.4.0?
  • Tried fish without third-party customizations (check sh -c 'env HOME=$(mktemp -d) fish')?

fish version installed (fish --version): 2.4.0-111-g7356987

OS/terminal used: Windows 10, Mintty

Activity

  1. faho commented on Nov 12, 2016

    @faho
    Member

    There have been times I've wanted this as well. Note that there's a nice little hack that you can use with commandline.

    # Assuming same $var as before
    commandline -r -- $var
    set list_var (commandline -opc)
    commandline -r -- ""

    Though really that just has some novelty value to it and shouldn't be actually used.

  2. floam commented on Nov 13, 2016

    @floam
    Member

    Makes sense to me to add this.

  3. added this to the fish-future milestone on Nov 13, 2016
  4. locked as resolved and limited conversation to collaborators on Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions