psutils icon indicating copy to clipboard operation
psutils copied to clipboard

touch fails when running in strict mode

Open kimbirkelund opened this issue 6 years ago • 1 comments

Most of my scripts calls Set-StrictMode -Version Latest; initially, and I've noticed that touch fails in this mode:

Set-StrictMode -Version Latest; 
touch <file>

The property 'A' cannot be found on this object. Verify that the property exists.     
At ...\touch.ps1:45 char:4                          
+ if($opts.A) {                                                                       
+    ~~~~~~~                                                                          
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : PropertyNotFoundStrict                                  

This can either be fixed by not accessing hashtable contents as members, but using the indexer, or by calling Set-StrictMode -Off at the beginning of the file.

Hope you fix this as I love your tools :-) And I'd be happy to make a PR with the change you'd prefer.

kimbirkelund avatar Jul 25 '18 05:07 kimbirkelund

Thanks, I'd be happy to accept a PR. Set-StrictMode -Off sounds good to me

lukesampson avatar Jul 25 '18 05:07 lukesampson