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

Update install.bat #958

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

Update install.bat #958

wants to merge 2 commits into from

Conversation

tilkinsc
Copy link

@tilkinsc tilkinsc commented Jan 24, 2019

The problem here is that %errorlevel% is set on exit /b ]] and you pass it something funny. By adding rem=rem you can reuse a hack and get it still to execute correctly. You don't actually need to even set rem=rem you can just pass it nil, since nothing else in the script uses rem.

The problem here is that %errorlevel% is set on `exit /b ]]` and you pass it something funny. By adding rem=rem you can reuse a hack and get it still to execute correctly. You don't actually need to even set `rem=rem` you can just pass it nil, since nothing else in the script uses rem.
@codecov-io
Copy link

codecov-io commented Jan 24, 2019

Codecov Report

Merging #958 into master will decrease coverage by 4.65%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #958      +/-   ##
==========================================
- Coverage   83.59%   78.94%   -4.66%     
==========================================
  Files          90       88       -2     
  Lines       10696     8946    -1750     
==========================================
- Hits         8941     7062    -1879     
- Misses       1755     1884     +129
Impacted Files Coverage Δ
src/luarocks/admin/cmd/remove.lua 29.09% <0%> (-63.9%) ⬇️
src/luarocks/fs/lua.lua 25.13% <0%> (-62.5%) ⬇️
src/luarocks/admin/cmd/add.lua 36.25% <0%> (-56.7%) ⬇️
src/luarocks/admin/cmd/refresh_cache.lua 53.33% <0%> (-41.41%) ⬇️
src/luarocks/cmd/which.lua 62.5% <0%> (-37.5%) ⬇️
src/luarocks/core/sysdetect.lua 41.33% <0%> (-26.12%) ⬇️
src/luarocks/admin/cache.lua 58.49% <0%> (-22.65%) ⬇️
src/luarocks/cmd.lua 75.47% <0%> (-12.88%) ⬇️
src/luarocks/core/path.lua 82.35% <0%> (-11.77%) ⬇️
src/luarocks/cmd/config.lua 80% <0%> (-11.52%) ⬇️
... and 51 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a200cf...436ea03. Read the comment docs.

@Tieske
Copy link
Contributor

Tieske commented Jan 24, 2019

rem=nil alters the Lua environment if rem was already set to something else. The original rem=rem is better imo, since it does not alter the Lua environment.

Also if exit /b ]] returns a weird exit code (I didn't test it), then surely the right solution is to use exit /b and not exit /b 0 because in the latter case it always returns exit code 0, where in the former case it would leave the exit code unaltered and return the exit code that LuaRocks exited with, which is the right thing to do imo.

Or even better, make it explicit and do exit /b %ERRORLEVEL%.

@tilkinsc
Copy link
Author

tilkinsc commented Jan 24, 2019

Ahh thats true.
The ]] still gets processed as an argument.

Also, whats up with the dramatic code coverage declination?

@Tieske
Copy link
Contributor

Tieske commented Jan 25, 2019

Also, whats up with the dramatic code coverage declination?

no idea, did you use the latest master branch to create this PR?

@tilkinsc
Copy link
Author

Yes I did. I edited directly from the website.

@Tieske
Copy link
Contributor

Tieske commented Jan 28, 2019

nvm the coverage for now, it needs updating according to previous comments

@tilkinsc
Copy link
Author

The changes were made for rem=rem

@Tieske
Copy link
Contributor

Tieske commented Feb 1, 2019

But it is still forcing the exit code to 0 instead of returning the result from the call into Lua

hishamhm pushed a commit that referenced this pull request Dec 2, 2019
The problem here is that %errorlevel% is set on `exit /b ]]` and you pass it
something funny. By adding rem=rem you can reuse a hack and get it still to
execute correctly. You don't actually need to even set `rem=rem` you can just
pass it nil, since nothing else in the script uses rem.
hishamhm pushed a commit that referenced this pull request Jan 14, 2020
The problem here is that %errorlevel% is set on `exit /b ]]` and you pass it
something funny. By adding rem=rem you can reuse a hack and get it still to
execute correctly. You don't actually need to even set `rem=rem` you can just
pass it nil, since nothing else in the script uses rem.
@hishamhm
Copy link
Member

Do we still need this?

Looks like exit /b (with or without %ERRORLEVEL%) is a big rabbit hole, which I'm not keen on getting into:
https://stackoverflow.com/questions/66248276/difference-between-exit-b-and-exit-b-errorlevel

And from Lua's perspective that second added rem=rem is inside a Lua string, so it should never run, so I don't think that's necessary either.

But in practice, I don't think a lot of people rely on our install.bat's produced errorlevel (especially if it doesn't currently work!), and to be honest I'd rather eventually remove this script in favor of other installation methods.

If the current behavior is producing a spurious error message thanks to exit \b ]] I'd be happy to just change it to plain exit \b and put the ]] on its own line below.

If this is just producing a bogus errorlevel which goes mainly unnoticed, then I don't care much either way and I would just close the PR.

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.

None yet

4 participants