[Enhancement] Replace Batch Redirector with Shims #372
Comments
You have my interest. I have no idea what you are saying, but I don't like batch redirects. What are shim files in this scope? |
If it fails, it backs up to using the old method.
This allows shimgen to treat the entire arg as part of the argument, even when it includes spaces. This is especially important with paths that include spaces.
@Redsandro sorry for not catching you on this here - shims are exe files which simply act to pass through information. |
Is there any update on this? |
@ferventcoder will correct me if I am wrong, but I think this is in the latest alpha release. Try
Gary |
Yeah, sorry I meant to put a note back in here when I released the alpha. What Gary said. |
I noticed that portable version of SumatraPDF requires double quotation (actually triple as typed) to open files with spaces in path. Is it shimgen at fault? The real SumatraPDF.exe opens everything just fine with ordinary quotation for files with spaces. |
@mlt This is interesting. It should not be the case. It should be the same amount of quotation as normal from command line calls to sumatra. What do you need for that from your shell and what are you seeing that you need when you call the shimgen version? |
I feel like it removes one quotation level. For instance, I'd call real SumatraPDF "some file.pdf" however I have to SumatraPDF """some file.pdf""" with shim when running, e.g., from Far file manager in either case. It should be similar to regular cmd.exe . I guess "" is treated as a single quote when passed down. I noticed that something is not right when pdf association quit working in my Emacs Org mode setup with Chocolatey version of Sumatra. |
Well that is definitely incorrect behavior. Let's get to the bottom of where sumatrapdf On Thursday, March 13, 2014, Mikhail Titov notifications@github.com wrote:
Rob http://devlicio.us/blogs/rob_reynolds |
My wording in the first comment didn't make a whole lot of sense. I think you answered correctly though. |
@mlt I'm thinking you may have Emacs looking for |
Nope, didn't fix it, if I tested it correctly. I did
And it failed by opening 2 SumatraPDF windows one claiming it failed to open |
@mlt I see it stripping off quotes. Let me see what I can do. |
Could you release this as open source? I could really use something like this. |
I think in 99% cases NTFS is used that supports links or whatever it is called on Windows. Shall we use that by default and let OS and FS handle all instead of a separate EXE and just fall back to shimgen if no link functionality is available? Mikhail
|
Do you mean symbolic links? The support for symbolic links on Windows is very naive. If you make for example a symbolic link to an EXE and that EXE requires an external library, the symbolic link won’t resolve the relative path to it. This makes symbolic links on Windows unusable and useless in many cases, because many programs require external libraries. Unix-like systems don’t have this limitation. I think this is also the reason because shims are preferred here. |
Oops didn't think of that a I used mostly with non-executables. Can we make it as an option if there is no such dependencies? E.g. create SumatraPDF.exe.gui containing "ln" would create a symlink if FS supports it, if the file is empty, then shimgen. Mikhail
|
Another thing to consider is that creating a symlink is a privileged operation on Windows, so it would not work for regular users. |
Indeed, symlink creation requires privileges. However I just tried and a hardlink for SumatraPDF was created just fine with an unprivileged user and it works okay as it has no bundled DLLs/resources. I used Far File Manager 3 to create one with ALT+F6. I'm not sure what is an API call for that. |
Right, but we need it to work in almost all cases. How will we be able to detect that it works without actually running the application in some controlled state and seeing if it errors due to an unfound library? That's why we're moving to a shim. Still provides really good functionality over batches with minimal issue. |
I mean to give an option for packagers and keep the rest as is. For example, if we know that SumatraPDF.exe does not need anything else at all, I'd prefer to simply hardlink it if it is cumbersome to fix quotes unfolding. Placing |
@mlt we still support windows 2003 (and so does MS until 7/14/2015). |
@mlt right, I forgot about hard links. Coincidentally, Windows itself uses them for similar purpose, creating links in system32 (and other places) to exes and dlls in WinSxS (the unmanaged assembly cache). @ferventcoder hard links are fully supported in xp/2003 (actually, even in 2000). The convenient command line tool Oh, and the logic should fall back to shims in cases when the hard link obviously cannot be used, e.g. $ChocolateyBinRoot is on a different drive than $ChocolateyInstall\bin, or link creation fails (e.g. both variables seem to point to the same drive, but one or more of the directories is actually a NTFS junction pointing to a different drive or even a file share). |
@ferventcoder have you made any progress on the stripping of quotes issue? |
@georgehemmings This is done based on the call in the Win32 API, meaning Windows strips them out (http://stackoverflow.com/questions/9287812/backslash-and-quote-in-command-line-arguments & http://weblogs.asp.net/jgalloway/archive/2006/09/13/Command-Line-Confusion.aspx) - What I'll need to do is likely detect spaces and strap on quotes when found. Or just add quotes every time around arguments. |
Does |
@mlt thanks for pointing out the console window appears. I think I have fixed that (but not yet released). |
@mlt I have the spaces issue fixed. Should be a call like normal to that once you see the next beta/release go out. |
- shimgen can handle spaces in arguments now - shimgen does not open a window for GUI based apps
* stable: (chocolatey-archiveGH-372) shimgen improvements
This should be ready to go. |
I don't see the sources for shimgen anywhere. Are they available? |
Unfortunately not. Shimgen is closed-source proprietary software. Here’s the license text: https://github.com/chocolatey/chocolatey/blob/master/src/tools/shimgen.license.txt |
Use a shim generator to create shim executable files instead of batch redirect files.
Shims are like symlinks except they work better. They are an executable that just runs another executable (or command). These shims are generated during the install and point only to the relative path of the executable. They are tiny at 11K.
The text was updated successfully, but these errors were encountered: