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

Program Environments / Variables #27

Open
2 tasks
nixpulvis opened this issue Oct 16, 2018 · 2 comments
Open
2 tasks

Program Environments / Variables #27

nixpulvis opened this issue Oct 16, 2018 · 2 comments
Labels
L1: enhancement New feature or request M: process Module: Process exec/fork and IO M: program Module: Oursh language(s) with lexers, parsers and evaluation runtimes. T: expansion Topic: '$' and other expansion T: grammar Topic: Formal or informal grammar, realtes to lexing / parsing T: semantics Topic: Program evaluation issues or features
Milestone

Comments

@nixpulvis
Copy link
Owner

nixpulvis commented Oct 16, 2018

POSIX shell scripts like most programs have a notion of bindings with scope. We need to implement the syntax fo assigning (FOO=1) and referencing ($FOO) variables. As part of loading a program it's default environment should be loaded appropriately. The environment variable $ENV denotes the complete working environment for a POSIX program.

Related to #43.

@nixpulvis nixpulvis added L1: enhancement New feature or request T: grammar Topic: Formal or informal grammar, realtes to lexing / parsing T: semantics Topic: Program evaluation issues or features labels Oct 16, 2018
@nixpulvis nixpulvis added this to the POSIX milestone Oct 16, 2018
@nixpulvis nixpulvis mentioned this issue Oct 16, 2018
12 tasks
@nixpulvis nixpulvis changed the title Program Environments Program Environments / Variables Oct 16, 2018
@nixpulvis nixpulvis mentioned this issue Oct 26, 2018
2 tasks
@nixpulvis
Copy link
Owner Author

First pass implementation merged in #51.

@nixpulvis nixpulvis added M: process Module: Process exec/fork and IO M: program Module: Oursh language(s) with lexers, parsers and evaluation runtimes. T: expansion Topic: '$' and other expansion labels Aug 13, 2021
@nixpulvis
Copy link
Owner Author

Key issue we need to fix is related to the scope of variables and their assignment, e.g X=1 echo $X should not print 1 as it does today.

Captured in a few preliminary tests here;

oursh/tests/posix.rs

Lines 125 to 128 in b064528

assert_posix!("X=1; echo $X", "1\n");
assert_posix!("X=1 echo $X", "\n");
assert_posix!("X=1; printenv X", "\n");
assert_posix!("X=1 printenv X", "1\n");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L1: enhancement New feature or request M: process Module: Process exec/fork and IO M: program Module: Oursh language(s) with lexers, parsers and evaluation runtimes. T: expansion Topic: '$' and other expansion T: grammar Topic: Formal or informal grammar, realtes to lexing / parsing T: semantics Topic: Program evaluation issues or features
Projects
None yet
Development

No branches or pull requests

1 participant