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

exec let-assignment to SAW String is not visible in Cryptol Term scope #1678

Closed
WeeknightMVP opened this issue May 27, 2022 · 3 comments
Closed

Comments

@WeeknightMVP
Copy link

WeeknightMVP commented May 27, 2022

e89a291 resolved #268, but this does not apply to assignments from exec (as of v0.9):

$ echo 'echo -n "mock"' > mock.sh
$ chmod +x mock.sh
$ saw
 ┏━━━┓━━━┓━┓━┓━┓
 ┃ ━━┓ ╻ ┃ ┃ ┃ ┃
 ┣━━ ┃ ╻ ┃┓ ╻ ┏┛
 ┗━━━┛━┛━┛┗━┛━┛ version 0.9



sawscript> let mock = exec "./mock.sh" [] ""
sawscript> mock
[02:47:29.867] "mock"
sawscript> print {{ mock }}

Cryptol error:
[error] at <stdin>:1:10--1:14
    Value not in scope: mock
sawscript> let mock = "MOCK"
sawscript> mock
[02:47:38.078] "MOCK"
sawscript> print {{ mock }}
[02:47:41.325] [77, 79, 67, 75]
sawscript> let mock = exec "./mock.sh" [] ""
sawscript> mock
[02:47:56.305] "mock"
sawscript> print {{ mock }}
[02:48:00.101] [77, 79, 67, 75]
@WeeknightMVP
Copy link
Author

WeeknightMVP commented May 27, 2022

One could abuse get_opt instead:

$ saw -I $(. mock.sh)
sawscript> let mock = get_opt 2
sawscript> print {{ mock }}
[12:34:56.789] [109, 111, 99, 107]

@robdockins
Copy link
Contributor

robdockins commented Jun 2, 2022

I think this has to do with the fact that exec has a result type TopLevel String, so you need to use a bind rather than a let.

sawscript> mock <- exec "./mock.sh" [] ""
sawscript> mock
[21:44:08.912] "-n mock\n"
sawscript> print  {{ mock }}
[21:44:13.244] [45, 110, 32, 109, 111, 99, 107, 10]

I'm not sure why I'm getting additional characters here when I do this... but otherwise I think this does what you want.

EDIT: I get what I expect if I force bash via #!/bin/bash in the script.

@WeeknightMVP
Copy link
Author

Thanks! Rookie mistake on my part.

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

No branches or pull requests

2 participants