Git Product home page Git Product logo

Comments (9)

chriscool avatar chriscool commented on July 29, 2024 1

@chu11 thank you for this issue.

I think it should work if you use make SHELL_PATH=/bin/sh test instead of make test.
It is also more flexible to not hardcode /bin/sh. And on some platform /bin/sh might be too old or not as feature complete as we need.

What could be done is to detect when the current shell is not appropriate and if that is the case to suggest using something like make SHELL_PATH=/bin/sh test instead of make test.

from sharness.

felipec avatar felipec commented on July 29, 2024 1

This can be closed now. My patch (0dddcc9) was merged in 2019.

from sharness.

chu11 avatar chu11 commented on July 29, 2024

@chriscool That seems like a good idea, to simply just warn the user if bourne shell isn't used. I think the main issue for me was just seeing tons of failures of 'make test' and not sure what to make of it.

from sharness.

anarcat avatar anarcat commented on July 29, 2024

which shell does sharness depend on anyways? sh or bash?

from sharness.

chriscool avatar chriscool commented on July 29, 2024

Sharness should work with most sh compatible shells. There are no strict rules, but there are some guidelines about what can be used in the Git documentation:

https://github.com/git/git/blob/master/Documentation/CodingGuidelines

from sharness.

anarcat avatar anarcat commented on July 29, 2024

so i guess the question is whether it does work with ash or dash. did anyone test that?

switching to /bin/sh can have pretty bad consequences where that shell is not bash, if there are bashisms in the code. this would need to be tested explicitly, IMHO.

from sharness.

chriscool avatar chriscool commented on July 29, 2024

On Ubuntu machines /bin/sh is dash and it works. I don't know about ash, but when reviewing PRs I take care about not accepting bashisms.

About testing this, yeah we could use https://www.shellcheck.net/ as it detects bashisms.

from sharness.

felipec avatar felipec commented on July 29, 2024

The code code from Git's test-lib where all the code is supposed to be POSIX compatible, so there really is no need to discuss which shell to use; it's /bin/sh.

--- a/sharness.sh
+++ b/sharness.sh
@@ -51,7 +51,7 @@ export SHARNESS_TEST_SRCDIR
 export SHARNESS_ORIG_TERM
 
 # Export SHELL_PATH
-: "${SHELL_PATH:=$SHELL}"
+: "${SHELL_PATH:=/bin/sh}"
 export SHELL_PATH
 
 # if --tee was passed, write the output not only to the terminal, but

Git also defaults to /bin/sh.

Now, if for some reason you want to use a different shell, just do: make SHELL_PATH=/bin/zsh test, and you can be happy knowing that you made everything fail.

However, defaulting to currently running shell is certainly one of the worse choices to make.

from sharness.

chriscool avatar chriscool commented on July 29, 2024

See: https://github.com/git/git/blob/master/Documentation/CodingGuidelines#L1-L19 for how Git handles POSIX compatibility.

I tend to agree with @felipec 's patch and plan to merge his merge request (#93).

We use https://www.shellcheck.net/ to detect bashisms and avoid potential compatibility isues now by the way.

So I think I will close this issue when merging @felipec 's patch.

from sharness.

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.