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

A single function to print the shell's state #715

Open
andychu opened this issue Apr 17, 2020 · 1 comment
Open

A single function to print the shell's state #715

andychu opened this issue Apr 17, 2020 · 1 comment

Comments

@andychu
Copy link
Contributor

andychu commented Apr 17, 2020

Right now there is this hodgepodge:

shopt -p -o   # print POSIX global options, alternative to 'set -o'
shopt -p # print bash global options
declare -p  # print variables, with their flags.  note: this doesn't distinguish scopes
declare -f  # print functions  ('set' without args also doe sthis)
trap  # print traps

(not needed: ${var@a} because declare -p prints those flags)

and there's probably more...

  • So Oil can either provide this function or provide an alternative. Maybe a generalization of the repr builtin
    • declare -p uses QSN now (well-defined string serialization). But you need eval because it looks like var=$'QSN'
    • trap takes a string of code, so it can also use QSN

Other formats:

  • there could be some other consistent format, like the ASDL dump format that repr uses
    • is it parseable?
    • I think we mostly need a map, like (cell exported:T readonly:F nameref:F val:(value.Str ...))
      • although the type "tag" is also useful
  • binary?

related to #704

@andychu
Copy link
Contributor Author

andychu commented Apr 17, 2020

This is also related to #708 because the stack is part of the shell's state

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

No branches or pull requests

1 participant