Skip to content
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
Closed

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

kbauer opened this issue Nov 12, 2016 · 2 comments
Labels
Milestone

Comments

@kbauer
Copy link

@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
Copy link
Member

@faho 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
Copy link
Member

@floam 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 Enhancement: Provide a `string unescape` subcommand. 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
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.