Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posix sh #237

Open
wants to merge 116 commits into
base: master
Choose a base branch
from
Open

Posix sh #237

wants to merge 116 commits into from

Conversation

grayed
Copy link
Contributor

@grayed grayed commented Oct 3, 2020

The portability fans are back! :-)

There were a few things broken already. In particular, a few places had "$foo" instead of $foo, breaking the intended words expansion.

The bash arrays were replaced with either simple expansion, or written directly, resulting in no code quality loss.

The zsh bits are only needed if someone will ever run "zsh cht.sh" and could be dropped; when zsh is working as sh, the shwordsplit option gets set automatically.

The local/typeset/declare case is the most complicated one. Technically, POSIX just reserves "local", "typeset" and "declare" for use by shell, keeping them as undefined behavior. All the shells I've tested with (bash, dash, ksh93, OpenBSD ksh, zsh) support either "local" or "typeset" command. But for better compatibility sakeness, since it was meaningful enough for 884161c, the "eval" fallback was implemented. This makes "local foo" invalid, thought, so I had to replace all of them with "local foo=" instead. But the better option likely be just ignoring shells that do not support local-scoped variables, since the code is likely to break in this case anyway.

@chubin
Copy link
Owner

chubin commented Oct 4, 2020

@grayed Vadim welcome back! I'm very very (very) glad to see you again.

Thank you very much for the fixes (have you run the tests?),
and I am (again) very glad that you are back, additionally to all other reasons
because I plan to do a crazy thing, where a fresh look of a shell-portablity expert would be really helpful :)

@grayed
Copy link
Contributor Author

grayed commented Oct 5, 2020

Nope, I've totally missed the fact that tests exist. Is there any reason to not run them in GitHub CI? If not, will you accept a PR that adds appropriate GitHub actions then?

@grayed
Copy link
Contributor Author

grayed commented Oct 5, 2020

Here are results of running tests on OpenBSD: https://gist.github.com/grayed/4257f05f399df44753a3619ce7d18101

Before tweaks from the PR there was no success at all, BTW, due to broken arguments passing.

The results vary from run to run, sometimes there are 9 successfull tests, sometimes 8. I didn't dig into them, though, since there is too much Python for me now. :-\

@chubin
Copy link
Owner

chubin commented Oct 5, 2020

since there is too much Python for me now

You didn't guess! This crazy test (and it is actually, just one test, but with several test cases) is written in bash.
The main problem here, as far as I can judge, that if you start it in the server mode, it does not work
(probably because of some problems that greenlet has in OpenBSD).
But you can start in the "standalone" mode (see inside the script how you can switch it),
so that no greenlets will be used. Then we will see what is missing

Regarding your question, why the test is not running in CI,
you are absolutely right, and the only one who is guilty is me.
I believe your question will be the final drop that will make me to fix it

@grayed
Copy link
Contributor Author

grayed commented Oct 7, 2020

Well, the tests are run by shell script, yes, but they try to run Python code, and it looks like something doesn't work there well. Still do not have enough time to look throughly. :(

I've sent another PR, with GitHub action draft, maybe it'll help. :)

@chubin
Copy link
Owner

chubin commented Oct 12, 2020

$Thank you for the fixes; actually we have CI, and eactly these tests are running there (we use travis-ci),
but there are some minor fixes to be done (#224). I hope to fix it first, and then we can continue with this pull request

@abitrolly
Copy link
Collaborator

Well, this needs to be rebased to become mergeable. :D

grayed and others added 17 commits November 18, 2021 01:22
…erly handle CHTSH environment variable, which override default CHTSH_HOME path
`--connect-timeout` didn't work, because Docker allows it, but breaks,
because nothing is listening on the other side, giving this error.

    $ curl --connect-timeout 10 http://localhost:8002
    curl: (56) Recv failure: Connection reset by peer
    The command "curl --connect-timeout 10 http://localhost:8002" exited with 56.

https://travis-ci.org/github/chubin/cheat.sh/builds/741348053#L401

`--retry-all` makes `curl` retry on all errors, including connection resets.
Because even Ubuntu 20.04 version of `curl` is outdated
Because at least live reloading doesn't seem to work with `gevent`
Co-authored-by: Anatoli Babenia <[email protected]>
…hlorenz/doctoc  The documentation was so nice, I couldn't help but adding a toc.
    CHEATSH_UPDATE_TESTS_RESULTS=YES bash run-tests.sh
`colored` became smarter in patch version to avoid
coloring if running without TTY

https://gitlab.com/dslackw/colored/-/issues/21
`universal_newlines` make this in compatible way with older Python.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.