V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
whoami9894
V2EX  ›  问与答

powershell 的转义规则

  •  
  •   whoami9894 · 2020-08-13 15:23:10 +08:00 · 654 次点击
    这是一个创建于 1377 天前的主题,其中的信息可能已经有所发展或是发生改变。

    MSDN: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7

    好奇葩

    PS C:\> python .\t.py 'a"b'
    ['.\\t.py', 'ab']
    PS C:\> python .\t.py 'a`"b'
    ['.\\t.py', 'a`b']
    PS C:\> python .\t.py 'a\"b'
    ['.\\t.py', 'a"b']
    PS C:\> python .\t.py 'a""b'
    ['.\\t.py', 'ab']
    PS C:\> python .\t.py 'a""""b'
    ['.\\t.py', 'a"b']
    
    
    PS C:\> python .\t.py "a'b"
    ['.\\t.py', "a'b"]
    PS C:\> python .\t.py "a\'b"
    ['.\\t.py', "a\\'b"]
    PS C:\> python .\t.py "a`'b"
    ['.\\t.py', "a'b"]
    
    
    PS C:\> python .\t.py "a""b"
    ['.\\t.py', 'ab']
    PS C:\> python .\t.py "a`"b"
    ['.\\t.py', 'ab']
    PS C:\> python .\t.py "a""""b"
    ['.\\t.py', 'ab']
    PS C:\> python .\t.py "a""""b"
    ['.\\t.py', 'ab']
    PS C:\> python .\t.py "a""""""b"
    ['.\\t.py', 'a"b']
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3123 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 04:17 · PVG 12:17 · LAX 21:17 · JFK 00:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.