Product, version and build: PS 207
Operating system: win 10
PowerShell version(s): 5.1
Hi,
I had a piece of code that has been running successfully every day for years that started to fail last week.
The line was:
$etime = "{ 0:g }" -f $elapsedtime
The problem was that there was a space after the opening brace and one before the closing brace.
This bit of code has not been edited for years. The only possible reason I can think of is that I often press 'format script' after making changes.
Might the 'Format Script' logic put spaces in something like the above?
Thanks
David
Format script issue?
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Format script issue?
Generally, the contents of strings are not formatted.
Having said that, the latest build (5.8.209) did address a bug in the formatter. While I was not able to get the line to add spaces, it could be related.
Please try build 5.8.209 and let me know.
Having said that, the latest build (5.8.209) did address a bug in the formatter. While I was not able to get the line to add spaces, it could be related.
Please try build 5.8.209 and let me know.
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Format script issue?
I have another one re: format script.
This line stopped working a little while ago. It has been running for years and has never been modified since first created - except by format script.
(this may have been fixed by 209 but given the two issues I have had I am too scared to run format script any more in case it breaks more stuff)
The problem is that a space was insert after the semicolon before the string member which caused the command to fail.
This line stopped working a little while ago. It has been running for years and has never been modified since first created - except by format script.
(this may have been fixed by 209 but given the two issues I have had I am too scared to run format script any more in case it breaks more stuff)
Code: Select all
DSACLS.EXE "\\$($global:pstoolObject.ActiveSiteDC)\$GroupDN" /G "$($global:pstoolObject.DomainNetbios)\$($ManagerSAM):WP; member" | out-null
Re: Format script issue?
I'm slightly confused by your statement. Are you running build 209 currently? Are you saying this happened from the previous build?
I'm currently testing with build 209 and have been unable to reproduce this behavior. What are your Formatting settings in options:
I'm currently testing with build 209 and have been unable to reproduce this behavior. What are your Formatting settings in options:
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Format script issue?
I have the same options except I have automatically indent new lines and align hash table equal signs checked. Parameter line spacing is also set to 0.
I have a habit of pressing 'Format Script' before I save any file.
I can honestly say with hand on heart that the two examples I have given are lines that I have not modified for years. No-one else edits my code.
The only possible explanation I can see is that the format script option changed the code.
Im not exactly sure when the problem occurred but it would have been in the last few months.
So I may have been running 206,207 or 208.
I tend to upgrade a day or two after the new updated has been released.
Thanks
David
I have a habit of pressing 'Format Script' before I save any file.
I can honestly say with hand on heart that the two examples I have given are lines that I have not modified for years. No-one else edits my code.
The only possible explanation I can see is that the format script option changed the code.
Im not exactly sure when the problem occurred but it would have been in the last few months.
So I may have been running 206,207 or 208.
I tend to upgrade a day or two after the new updated has been released.
Thanks
David
Re: Format script issue?
Let's say you do find some 'irregularities' that were introduced into the 'format script' routine.
I would very much appreciate if you could publish the 'pseudo logic' that caused the above problems so that I can check all my code for any other issues.
Thanks
David
I would very much appreciate if you could publish the 'pseudo logic' that caused the above problems so that I can check all my code for any other issues.
Thanks
David
Re: Format script issue?
The only verified issue found in the formatter with the current build (5.8.209) was the following:
viewtopic.php?p=83132#p83132
I have not been able to reproduce the behavior described with the information provided. Was the line provided part of a longer script? If so, it could be an earlier line that causes this issue. Can you upload the script here to help us reproduce this?
https://www.sapien.com/support/upload
viewtopic.php?p=83132#p83132
I have not been able to reproduce the behavior described with the information provided. Was the line provided part of a longer script? If so, it could be an earlier line that causes this issue. Can you upload the script here to help us reproduce this?
https://www.sapien.com/support/upload
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Format script issue?
I work for a govt department that does not allow this sort of stuff to be sent outside of the organisation.
I do fail to understand how an 'earlier line' could possibly influence the 'format script' routine.
That suggests to me that the format script routine introduces random spaces within quotes based on some earlier code?
Remember that this problem could have been caused by 206, 207 or 208. As it is impossible to say when exactly the problem occurred and when I installed those versions. All I can narrow it down to is some time in the last few months.
I do fail to understand how an 'earlier line' could possibly influence the 'format script' routine.
That suggests to me that the format script routine introduces random spaces within quotes based on some earlier code?
Remember that this problem could have been caused by 206, 207 or 208. As it is impossible to say when exactly the problem occurred and when I installed those versions. All I can narrow it down to is some time in the last few months.
Re: Format script issue?
The file is parsed before it is formatted. If a line in a script is parsed incorrectly, then it can cause issues with the remaining script being parsed. This can lead to errors with syntax coloring and code formatting. As I previously stated, strings are not generally formatted and with the information you have provided, I can not reproduce any such behavior as you are describing. There was a bug found in build 208 that was related to formatting hash tables and specifically the option to align the equal signs in hash tables. This issue, as far as I know, was resolved in build 209.
Please provide a script demonstrating the behavior you have described so we can get this fixed for you:
https://www.sapien.com/support/upload
Please provide a script demonstrating the behavior you have described so we can get this fixed for you:
https://www.sapien.com/support/upload
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.