Code Monkey home page Code Monkey logo

Comments (4)

JohnoKing avatar JohnoKing commented on September 28, 2024 1

This bug was originally reported in att#7. It is caused by the following section of code, which does not save the state of variables in a newer scope:

/* don't bother to save if in newer scope */
if(sp->var!=shp->var_tree && sp->var!=shp->var_base && shp->last_root==shp->var_tree)
return(np);

I have made a pull request (#16) to fix this bug.

from ksh.

McDutchie avatar McDutchie commented on September 28, 2024

For the acronym-deficient: SSCCE. Take your pick, all of them might apply... ;)

Meanwhile, I've found that if we change the second function's form to that of a POSIX subshell function definition:

unset a b
c=0

function set_ac { a=1; c=1; }
set_abc() ( set_ac ; b=1 )

set_abc
echo "a=$a b=$b c=$c"

…the bug vanishes. Which suggests to me that it is probably a bug in the parser, and not so much in the subshell mechanism itself. It appears that the subshell in your original SSCCE is wrongly optimised out.

from ksh.

McDutchie avatar McDutchie commented on September 28, 2024

My suspicion that it was a parser issue looks to be wrong. If you change set_abc() back into a ksh-style function and defeat any possible optimisation by adding an extra command:

function set_abc { ( set_ac ; b=1 ); echo end; }

…then the bug still occurs.

from ksh.

McDutchie avatar McDutchie commented on September 28, 2024

Fixed by #16. Many thanks @JohnoKing!

from ksh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.