-
Notifications
You must be signed in to change notification settings - Fork 452
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
fix: powershell does not support $? operator, or # for comments #70
base: main
Are you sure you want to change the base?
Conversation
I think the $? vs $LASTEXITCODE change is necessary. |
The problem with the "#" is the way its being used is it is trying to execute a program called "#". If you look at the log files, something akin to "The application '#' cannot be found" is displayed. Now, it doesn't stop execution of the script but you get a bunch of unnecessary warning messages. Using "echo" achieves the intended purpose. |
Actually, is it even running PowerShell... it's |
I think the changeset is correct, but the explanation is off. cmd shell does not support $? or # comments. But powershell does. The change is compatible with cmd shell. |
|
I don't have a background in Windows servers, so I don't know if its cmd or powershell, but I can say that I (painstakingly) took the time to deploy the LZA multiple times to arrive at this pull request and the values I suggest provide working and clean output. %ERRORLEVEL% may also work, I have no idea, but I can also guarantee you from actually deploying it that $LASTEXITCODE does indeed work. |
I've got a pretty strong Windows background. |
Got it. Thanks for the clarification @dbaileyut ! That makes sense. |
Issue #, if available:
No issue, but I can create one if necessary.
Description of changes:
cfn-signal fails to execute as powershell does not recognise "$?" and instead on Windows we need to use "$LASTEXITCODE". The error given in the logs is: "cfn-signal: error: option -e: invalid integer value: '$?'"
Also starting a command with "#" will also fail. This seems like it was intended to be a comment in the logs, so used "echo" instead.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.