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
Add tests for Qw, Qx and Qww. One more test for qx to check how two backslashes are interpreted #182
Conversation
…ackslashes are interpreted
| @@ -524,6 +527,8 @@ Hello, World | |||
| my $var = 'world'; | |||
| is qx/echo world/.chomp, "world", 'qx'; | |||
| is qqx/echo $var/.chomp, "world", 'qqx'; | |||
| is Qx[echo '\\'].chomp, "\\\\", "Qx treats backslash literally"; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test fails. With different failure modes on Debian and on Windows, because Windows uses " as shell quoting character:
Debian:
not ok 1 - Qx treats backslash literally
# Failed test 'Qx treats backslash literally'
# at z.p6 line 4
# expected: '\\'
# got: '\'
Windows:
not ok 1 - Qx treats backslash literally
# Failed test 'Qx treats backslash literally'
# at p.t line 4
# expected: '\\'
# got: ''\\''
| @@ -524,6 +527,8 @@ Hello, World | |||
| my $var = 'world'; | |||
| is qx/echo world/.chomp, "world", 'qx'; | |||
| is qqx/echo $var/.chomp, "world", 'qqx'; | |||
| is Qx[echo '\\'].chomp, "\\\\", "Qx treats backslash literally"; | |||
| is qx[echo '\\'].chomp, "\\", 'qx escaping a backslash returns one backslash'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test fails on Windows, as it uses " quotes for shell escapes:
# Failed test 'qx escaping a backslash returns one backslash'
# at p.t line 5
# expected: '\'
# got: ''\''
…o it works on Windows as well as POSIX shell
|
It should pass now I think on Windows and POSIX environments. Since echo on Windows leaves quotation marks in, and on POSIX we need them to treat the contents literally, compare zsh and tcsh's builtin echo does not properly follow POSIX. Although worst case would be that the test would pass when it shouldn't, we can do better than this. We fix this with the extra slashes. As you can see all the below are different, and the test is functional on POSIX compliant and noncompliant echo's If something went wrong and Qx has sent half as many slashes as expected, this should detect it without assuming which shell the user has set as the system shell. |
|
Thanks a lot! |
No description provided.