GithubHelp home page GithubHelp logo

run k-script-build correctly about oil HOT 14 CLOSED

oilshell avatar oilshell commented on July 24, 2024
run k-script-build correctly

from oil.

Comments (14)

andychu avatar andychu commented on July 24, 2024 1

OK I fixed the two bugs you mentioned.

Then I cloned the repo and did the self-hosting step. I was able to parse all ~2600 lines of code in the project with OSH.

Running it, OSH completes (in 15 seconds on my machine), but gives the wrong results. It looks like tabs are messed up, and the file is much shorter.

I will look into these issues more. I may have questions later. Thanks, this is a great test case!

from oil.

stephenreay avatar stephenreay commented on July 24, 2024

Ah. The printf issue seems to be because of backslash escaping, see basic repro in https://gist.github.com/stephenreay/339d01d6fc6239c3089810cbdca2f4cf

from oil.

stephenreay avatar stephenreay commented on July 24, 2024

Ok, and I've got a repro for the [ ... -a ... ] issue too. Same gist. https://gist.github.com/stephenreay/339d01d6fc6239c3089810cbdca2f4cf#file-test-and-or-sh

from oil.

andychu avatar andychu commented on July 24, 2024

OK thanks, this is great! I just ran both gists and got the unexpected results. The first one is a simple oversight. I have to look deeper into the second one. Should have fixes soon though.

from oil.

stephenreay avatar stephenreay commented on July 24, 2024

Great! I added you to the repo for (amongst other things) k-script-build.

Once you have it checked out ./configure && make k-script-build-static should produce (via self-hosting) a working script with everything inlined so you don't need to install the library files for the paths to work.

The makefile uses that same static script when building the distribution targets (ie the relatively linked source script builds a temporary static inlined script, which builds the absolutely linked installable script)

from oil.

stephenreay avatar stephenreay commented on July 24, 2024

Nice work. Happy to help, so sure send me any questions you have, and/or I'm happy to trial against updated OSH builds too.

from oil.

andychu avatar andychu commented on July 24, 2024

So after some inspection and debugging I think the rest of the errors are due to the fact that the read builtin doesn't currently respect IFS, and that's used in several places in the script.

I could implement that, but unfortunately I think it will make the script even slower than the 15 seconds it takes now! I already know I have to optimize the IFS splitting algorithm because it's a bottleneck elsewhere.

So I'm going to leave this open, but I probably won't get to it for a couple months, until after I optimize the parser.

But this is a really good benchmark because it spends significant time in shell! Most shell scripts spend most of their time in external utilities, but this does significant work in shell itself.

If you can think of any other shell scripts to run OSH on, please do and file bugs :) Thanks.

from oil.

stephenreay avatar stephenreay commented on July 24, 2024

from oil.

andychu avatar andychu commented on July 24, 2024

Hi Stephen, I'm implementing IFS with read right now. (I ran into this in multiple places. I see other people using this for packaging shell scripts into a single file.)

After I do this, I think OSH should be able to pass your tests.

It looks like the repository still private (or at least I get a login screen visiting it)? If it's OK with you, I'd like to include your test as part of my test suite, since it is a self-contained program with a well-defined output. Is there something you are planning to do before making it public? Thanks.

from oil.

stephenreay avatar stephenreay commented on July 24, 2024

Hey Andy,

It's great to hear you're making progress!

It's fine to include it, and I think I'm OK to make it public now too. If you want to include files/etc directly in the osh repo please feel free to proceed, if you want to link to my repo and have it work for others, I'll aim to get it done this week.

from oil.

andychu avatar andychu commented on July 24, 2024

OK great, I finished implementing read with IFS. I ended up rewriting the hairy IFS algorithm with an explicit state machine, which fixed a lot of bugs and failing tests. I'm happy with how it turned out.

I will try it out on your scripts shortly. Thanks a lot!

from oil.

andychu avatar andychu commented on July 24, 2024

OK I got it working! I checked the output script and both have the same checksum. I think the main issue was that I had to rewrite the IFS splitting algorithm and have read use it.

It takes 40 seconds with OSH vs 0.6 seconds for bash on my machine. Well, now that it works, it can be optimized :)

Thanks for the test case!

~/hg/wild/shell-script-library$ sha1sum k-script-build-static k-script-build-static-OSH 
7bf59775a7e3b175da284a1268ba437c94d77573  k-script-build-static
7bf59775a7e3b175da284a1268ba437c94d77573  k-script-build-static-OSH

from oil.

andychu avatar andychu commented on July 24, 2024

Fixed in 0.4.0 http://www.oilshell.org/blog/2018/02/03.html

from oil.

stephenreay avatar stephenreay commented on July 24, 2024

Hey @andychu, FYI, despite a huge delay the koalephant-shell-script-library project is now in an open repo.

The k-script-build tool has also had some changes, which may affect how/if it runs under OSH still - it's doing more of the key stuff directly in shell where it used to rely on sed. This mostly relates to pattern matching of strings.

The URL is the same (https://bitbucket.org/koalephant/shell-script-library) and I'm putting up release version tarballs in the 'downloads' page too, if thats easier for testing with.

Let me know if I can help at all.

from oil.

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.