PowerShell逃脫字元問題 - Windows
By Olivia
at 2020-10-27T19:53
at 2020-10-27T19:53
Table of Contents
作業系統: Windows 10
Service Pack: 20H2
發生問題頻率: 100%
是否有做Windows Update: 有
問題內容:
據我所知Powershell中要表示
字元` = '``' = "````"
字元' = '''' = "`'"
字元[ = '`[' = "``["
字元] = '`]' = "``]"
依此類推...
# D:\`[test`]'`
test-path 'D:\```[test```]''``'
test-path "D:\``````[test``````]`'````"
# E:\`[test`]'``
test-path 'E:\```[test```]''````'
test-path "E:\``````[test``````]`'````````"
以上皆如預期回傳 True
# D:\`[test`]'`
test-path 'D:\```[test```]''`'
test-path "D:\``````[test``````]`'``"
# E:\`[test`]'``
test-path 'E:\```[test```]''```'
test-path "E:\``````[test``````]`'``````"
上面這些怎麼也全都回傳 True?
單引號內右側少了1個`
雙引號內右側少了2個`
想了一下...
看起來'`'或"``"右側沒有跟其他特殊字元相鄰時等同'``'或"````"
所以test-path中 '`' = '``' = "````" = "``````" = "````````"
怎麼會有這麼奇怪的行為? 還是我哪裡誤會了?
--
Service Pack: 20H2
發生問題頻率: 100%
是否有做Windows Update: 有
問題內容:
據我所知Powershell中要表示
字元` = '``' = "````"
字元' = '''' = "`'"
字元[ = '`[' = "``["
字元] = '`]' = "``]"
依此類推...
# D:\`[test`]'`
test-path 'D:\```[test```]''``'
test-path "D:\``````[test``````]`'````"
# E:\`[test`]'``
test-path 'E:\```[test```]''````'
test-path "E:\``````[test``````]`'````````"
以上皆如預期回傳 True
# D:\`[test`]'`
test-path 'D:\```[test```]''`'
test-path "D:\``````[test``````]`'``"
# E:\`[test`]'``
test-path 'E:\```[test```]''```'
test-path "E:\``````[test``````]`'``````"
上面這些怎麼也全都回傳 True?
單引號內右側少了1個`
雙引號內右側少了2個`
想了一下...
看起來'`'或"``"右側沒有跟其他特殊字元相鄰時等同'``'或"````"
所以test-path中 '`' = '``' = "````" = "``````" = "````````"
怎麼會有這麼奇怪的行為? 還是我哪裡誤會了?
--
Tags:
Windows
All Comments
By Andrew
at 2020-10-28T03:25
at 2020-10-28T03:25
Related Posts
outlook收到出現國外陌生郵件
By Hedda
at 2020-10-26T11:07
at 2020-10-26T11:07
PCman使用wss安全連線的問題
By Andy
at 2020-10-25T16:11
at 2020-10-25T16:11
Windows 10 1809版本更新問題
By Dorothy
at 2020-10-25T15:13
at 2020-10-25T15:13
如何複製資料夾中所有影片的時間長度
By Andy
at 2020-10-24T16:53
at 2020-10-24T16:53
Surface Duo特價開始
By Tristan Cohan
at 2020-10-24T02:06
at 2020-10-24T02:06