Giter Club home page Giter Club logo

Comments (3)

infertux avatar infertux commented on June 2, 2024 1

Thank you for this great snippet. However adding even more regexps to address all these examples feels wrong to me because there will always be weird edge cases that can't be handled by regexps. So I'm tagging this issue as a duplicate/reminder of #25

from bashcov.

pawamoy avatar pawamoy commented on June 2, 2024

Indeed, I managed to get a 65.91% coverage on this snippet with a Bash solution, using regular expressions and hacks, but without a lexer it will be impossible to get to 100%.

Something I find quite problematic is how the LINENO variable behaves.
With normal commands it's fine.
With commands in process substitutions ($(), ``, <(), >(), (), etc.), using backslashes \, pipes | and logical operators (&&, ||) (and without mentioning handling additional comments # in regexes, and weird eval cases), it's completely useless.
The line numbers I get are completely offset, sometimes overlapping with later lines, like empty lines, comments, or commands. It's indecipherable.

I wonder if we could get to 100%, even with a lexer, if the LINENO variable is not improved.
Bash says it itself:

LINENO Each time this parameter is referenced, the shell substitutes a decimal number representing the current sequential line number (starting with 1) within a script or function. When not in a script or function, the value substituted is not guaranteed to be meaningful.

(Emphasis mine)

Maybe a more reliable way would be to do heuristics to match the actual line using the value of LINENO and the command written in the trace log. LINENO gives you a close position in the file, the command helps you identifying the actual line.

I also wonder how Zsh handles this.

from bashcov.

pawamoy avatar pawamoy commented on June 2, 2024

More info on this stackoverflow post and in this gist I made in response.

from bashcov.

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.