New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement `string unescape` to complement `string escape` #3543

Closed
kbauer opened this Issue Nov 12, 2016 · 2 comments

Comments

Projects
None yet
4 participants
@kbauer

kbauer commented Nov 12, 2016

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

@faho faho added the enhancement label Nov 12, 2016

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Nov 12, 2016

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.

Member

faho commented Nov 12, 2016

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.

@floam

This comment has been minimized.

Show comment
Hide comment
@floam

floam Nov 13, 2016

Member

Makes sense to me to add this.

Member

floam commented Nov 13, 2016

Makes sense to me to add this.

@floam floam added this to the fish-future milestone Nov 13, 2016

@krader1961 krader1961 changed the title from Enhancement: Provide a `string unescape` subcommand. to implement `string unescape` to complement `string escape` Dec 24, 2016

@krader1961 krader1961 self-assigned this Jun 23, 2017

@krader1961 krader1961 modified the milestones: fish 2.7.0, fish-future Jun 23, 2017

krader1961 added a commit to krader1961/fish-shell that referenced this issue Jun 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment