-
Notifications
You must be signed in to change notification settings - Fork 931
(#1664) fix issues with % symbols in environment variable expansion
#1678
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
Conversation
replaced `::`s with `REM` to avoid "the system cannot find the drive specified" errors removed any pauses and the not-always-supported `ECHO | SET /P` syntax replaces `SET` with `CALL SET` to allow variables to resolve before setting (using !s would be another option potentially) Removes temp batch file after running Should differentiate between REG_SZ (or MULTI) and REG_EXPAND_SZ
% symbols in environment variable expansion% symbols in environment variable expansion
ferventcoder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, looks great so far!
I've noted a few things to fix up here. In addition, the commit also needs updated to follow the format we request in CONTRIBUTING.md (top level of repo).
Removed personal debug lines and in-line comments in addition to changing `echo.` and `echo ` to `echo/ Echo changes as per https://groups.google.com/forum/?hl=en#!msg/alt.msdos.batch.nt/VhNXmRQEcVk/J3-C8ViGOD0J Comment lines removed include [code] REM Just echo. Don't bother prompting. REM (WAS) set /p dummy="[text below] Press a key to continue..." REM (DEBUG) echo ParentKey: %~1 VarName: %~2 OutVarName: %~3 1>&2 REM (DEBUG) type "%temp%\_envset.tmp" 1>&2 REM (DEBUG) echo MatchFound: %~3 eq %%B 1>&2 REM (WAS) set /p dummy="Finished. Press a key to close window." [/code]
MPagel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(let me know if not in line with contributing.md)
made a few whitespace changes.
MPagel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good to go.
MPagel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
|
We'll be gearing back up to look at this soon! |
|
@MPagel I am starting to go through the backlog of PR's into this repository, apologies for not getting back to you sooner about this. Are you in a position to sign the CLA for the project? You can find it linked in the previous comment. Thanks |
% symbols in environment variable expansion% symbols in environment variable expansion
|
@gep13 didn't see your comment until now. All I see when I go to the cla page is "Please agree to the CLA for multiple repositories or organizations Version: " and then a text box which doesn't accept input. no confirm/deny button is present. |
|
@MPagel This is what I see when going to https://cla-assistant.io/chocolatey/choco?pullRequest=1678 And at the bottom of the page: If you are not seeing that, perhaps try a different browser, and disable any adblockers/anti trackers for the site |
|
finally updated and loaded on firefox. I believe I have signed it now. it doesn't say here that I have signed, but CLA assistant thanked me for signing and redirected me back here. |
I can confirm that this has now been signed, thank you! |
|
Dear contributor, As this PR seems to have been inactive for 30 days after changes / additional information |
|
@MPagel I appologies for everything taken so long, we are currently looking at attempting to pull this PR into the next release of Chocolatey CLI, and as part of that I have taken this PR for a test run. Unfortunately, from what I can tell, I am not able to see it fixing the issue that was reported (with the steps) in issue #1664. Can you confirm what it is that you expect to fix with this PR? Additionally, due to my limited understanding of bat/cmd, what is the reason for the use of for the |
|
Disclaimer: As it has been several years since I made the contribution, I'm only 99% sure of my comments to follow The echo/set construction was present in the pre-modified code (lines 61 and 62 in the PR do what line 46 did in the original). Basically, my understanding is it is appending a SET command into an _env.cmd file in the temp directory. The SET instruction is not immediately executed, rather this temp file is later executed during the course of the script (line 57 original). The modification in the PR IIRC should allow literal % values to be retained in the PATH environment variable, while allowing the expansion of other variables between two %s, as DOS itself allows. I just ran the "bobo" script in a windows 11 cmd window, and it performed exactly as indicated in the REM statements. Is this what you were not able to replicate? |
|
@MPagel thank you for getting back to us about this, we really appreciate it! We understand that it has been quite a while to get to this PR. I like to say that around here, sometimes the wheels turn slowly, but they do indeed turn! 😄 I am just working with @AdmiringWorm on this, and so far, we have not been able to validate that the changes you have made to the Like you, we have taken the bobo script, and ran it in a fresh Windows Command Prompt, and we get the same output as you. So that part is working as described. However, we have then taken the following steps...
i.e. with your changes to the Can you verify whether these steps actually work for you? Or are you doing something else? Looking at the Is that what you are expecting it to contain? Thanks again for your help with this! |
|
If we change the contents of the rather than: We can see that the contents of the |
|
Digging into this a little bit further, we just wanted to clarify that this only seems to be a problem on Windows Command Prompt, the same problem does not appear to happen when using Windows PowerShell. |
|
Looking at the to this: NOTE: The removal of |
|
thank you for the detailed breakdown of what you tried. IIRC the my use case was with the PATH environmental variable, so I don't know if that makes any difference from what you were trying. I also may not have tried with setx across different sessions, but MAY have just been trying to refresh the value within a single session. |
|
As there was a need to rebase and update the bat script to be compatible with the latest version of the We have left you as the original committer for the commits that were added to give proper attribution, but as it will be merged as a different PR I'll be closing this PR now. We do appreciate the work you have done, and the patience you have shown to get this added to Chocolatey CLI. |
Should differentiate between REG_SZ (or MULTI) and REG_EXPAND_SZ
replaced
::s withREMto avoid "the system cannot find the drive specified" errorsremoved any pauses and the not-always-supported
ECHO | SET /Psyntaxreplaces
SETwithCALL SETto allow variables to resolve before setting (using !s would be another option potentially)Removes temp batch file after running
Intended to address Issue #1664