Skip to content

Serializing scripts with selective escaping #7

Description

@cgohla

I have a use case for the following kind of function (nevermind the name):

bytes' :: [Identifier] -> Statement t -> Expression t

The idea is to obtain an escaped string literal (or some Concatenation of Literals and ReadVarSafes) representing the statement, but where the given identifiers are not escaped. I want to be be able to pass the resulting statement to eval while capturing the values referred to by the listed identifiers.

As an example, I want to be able to produce a script like this:

  baz=boom
  eval "foo=bar ; echo $baz\$foo"

which should output boombar.

I'm definitely going to try to implement this, but I haven't thought about the details.

Thoughts?

Alternative

One could use the existing bytes and apply some string replacement to remove the unwanted escapes, but this might get tricky when there are several levels of escapes involved.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions