Comments (7)
Interesting!
On-the-fly rewriting indeed solves this problem, though I suspect that the hacky approaches we've talked about will do fine. E.g., early expansion will turn $EXP
into export
and the analysis will see that MYVAR
is updated...
from pash.
I think that the problem is that the preprocessing step (that replaces parts of the script with calls to PaSh's runtime) does not expand. Since we are not tighly integrated, PaSh now "guesses" which areas could be potentially optimization worthy, and then at runtime, PaSh can expand and decide whether to optimize (but even if it doesn't optimize, we are now running in a different process/shell). Therefore $EXP $MYVAR
would be still executed from the PaSh runtime, making the export
not propagate to the top process.
Some more "hacky" alternative solutions to address this could be:
- When compiling the DFG back to a script, compile
export
to a custom export that both exports (so that the script works) but also keeps the exported variables in a log, which can then be used toreplay
all exported variables at the top script. - Ending the inside script with
bash
link - Is there a way to execute
pash_runtime
in the same shell (something likesource
orexec
), essentially seeing the changes in the environment that happen inpash_runtime
?
from pash.
Ah. One option would be to have pash_runtime
try to detect the issue, and then somehow rollback. Tricky in fully AOT setting.
If pash_runtime
were itself a shells script, running source
or eval
would let us see all of the internal shell state. But the moment you exec
(or run a program with execve
), only the exported state shows up. Which might be fine in this case?
The replay approach seems like a straightforward enough hack. But a practical question: does this come up? I imagine most of what pash_runtime
actually runs ends up in subshells/pipes, which would never affect the outer shell anyway.
from pash.
Ah. One option would be to have
pash_runtime
try to detect the issue, and then somehow rollback. Tricky in fully AOT setting.
Rollback indeed sounds tricky :(
If
pash_runtime
were itself a shells script, runningsource
oreval
would let us see all of the internal shell state. But the moment youexec
(or run a program withexecve
), only the exported state shows up. Which might be fine in this case?
It might be possible (and easy) to make pash_runtime
a shell script that we source
that contains:
- A python call to the pash_runtime that outputs the compiled, sequential (unmodified) or parallel (optimized) to a file
source
this file, executing it in the parent shell.
The replay approach seems like a straightforward enough hack. But a practical question: does this come up? I imagine most of what
pash_runtime
actually runs ends up in subshells/pipes, which would never affect the outer shell anyway.
In practice we could avoid the most common scenario of export X
by not replacing it with a call to the PaSh runtime. But this would leave the corner case I mentioned above ($EXP ...
) uncovered. We could certainly not cover this for now though.
Note that in all the above cases, the issue #57 remains and needs to be handled independently.
We could also discuss this in detail tomorrow :)
from pash.
Let's chat a bit about it tomorrow. I think there are hacks that could resolve #57 (e.g., just exporting all of the local variables to pash_runtime
, or doing an analysis to choose the live ones to export, or whatever), but it seems clear to me that the best answer is tighter integration, since it would resolve both of these issues.
from pash.
I agree! Let's discuss in detail tomorrow.
from pash.
I solved this issue for now with the source
method. The PaSh runtime is now a bash script that calls the python runtime. Issue #57 remains.
from pash.
Related Issues (20)
- Exclamation marks in string literal output get escaped HOT 1
- Parse error in gnulib-tool HOT 8
- Unnecessary "!" escape HOT 2
- Bump PaSh's python dependency to 3.7
- Add support for more distros in Github Actions CI
- Remove flag `--r_split` HOT 1
- Hide PaSh installation output by default
- Improving exception handling for debugging HOT 9
- Install the annotation library using pip from PyPI
- Fix links in benchmark descriptions
- Parallelize the call to the compiler with the execution of the command
- Add CI component that installs through up.binpash HOT 1
- awk argument issues HOT 6
- Refactor AST HOT 5
- Separate preprocessor and runtime from particular transformations (parallelizaton, speculation, etc.)
- Questions about pash. HOT 3
- Input files for benchmarks/oneliners cannot be found
- make_typed_semi_sequence doesn't exist
- Missing External Dependency - aclocal
- Setting IFS crashes PaSh
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pash.