Comments (6)
This is a technique known as tunneling. See https://ss64.com/nt/syntax-functions.html for a description of what the technique is used for. Simply put, it's a way to do something with setlocal environments variables before endLocal throws out the values of those local environment variables. EndLocal environment variables don't get removed until the command line finishes.
from asar.
Thank you very much for your help.
This is the first time I have heard the concept of tunneling, and its implementation is very cool.
There is a section of code in asar.cmd
that looks like this
call :func
goto :eof
:func
setlocal
set ret=1234
endlocal & goto #_undefined_# 2>nul || title %ret%
For goto #_undefined_# 2>nul
,
It seems to have intentionally made an error and then executed the statement after ||
But according to tunneling, the last line is changed to
endlocal & title% ret%
Can also successfully obtain %ret%
So is goto #_undefined_# 2>nul
completely redundant?
from asar.
That's right, the intentional error is done so that the code after the || is guaranteed to execute and that's of course where the local environment variable %ret% is used. When you see that technique used for the first time, it's certainly not obvious what's going on and it's certainly not explained in any online help documentation. By the way, nice question to ask since I think it'll be helpful to others who stumble here.
from asar.
Here's another link: https://ss64.com/nt/endlocal.html. It discusses the endlocal&set construct. It says that endlocal does not set or clear the errorlevel. Reading that, it sounds like "endlocal & title %ret%' would work without the "goto #undefined# 2>nul" line. The fact the endlocal does not set or clear the errorlevel adds a certain level of confusion as to how "endlocal& is implemented by the shell. By adding the redundant "goto" statement, it certainly removes some of that ambiguity. I'm not sure but this might be a way to quarentee that the code works in different shells (i.e. cmd, powershell and windows powershell, bash.) This is what I just hate about writing batch scripts, the code just isn't clear!
from asar.
FWIW the CMD file is provided by Node.js when you install asar
, so the maintainers of this repo have no context as to its construction.
from asar.
This seems to be fixing the errorlevel
to 1, possibly related to error handling
from asar.
Related Issues (20)
- Run extracted content without packing it back again HOT 1
- ASAR file format HOT 1
- Create asar fails for nested empty directories: `Cannot read property 'files' of undefined` HOT 1
- bug: extractAll crashing because of non-existent file HOT 3
- There is an error that seems to be caused by soft links
- dynamic import not working inside asar HOT 5
- Typescript rewrite? HOT 1
- uncache/uncacheAll purpose?
- No error if asar file cannot be written to disk? HOT 4
- `@types/glob` should be a dev dependency, not an optional dependency. HOT 1
- What does 'Asar' stand for? HOT 2
- https://github.com/alibaba-open-source-website/Chat2DB/commit/691f4ce1e48b5aaa3a420c576fc7c560b1ff69c1
- Can not import a js file from asar HOT 1
- Incorrect integrity of transformed files? HOT 2
- BUG: asar command fails with "module not found" HOT 2
- Recursive rmdir returns error while trying to remove folder, that contains asar file. HOT 1
- just a theory
- Symlinked directories not included in asar
- Error in getNode while accessing symlink
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asar.