Open fbenkstein opened 6 years ago
Does this have a chance of being merged? I understand if you think it adds to much complexity, I'll just roll my own module then.
Can shells deal with non-ASCII bytes with the normal '
quoting or do they need to be further escaped into an octal sequence or something like that?
I think non-ascii bytes do not need to be escaped. I‘ll do some research to come up with some evidence.
The way I read http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html is that only
| & ; < > ( ) $ ` \ " ' <space> <tab> <newline> * ? [ # ˜ = %
need to be quoted. As for non-ascii, I believe that http://pubs.opengroup.org/onlinepubs/009696899/basedefs/xbd_chap06.html says that (assuming the character set is ASCII based) the non-ascii characters just represent themselves without any need for escaping.
I could add an integration test. For example, we could create a file in a temporary directory, call $SHELL -c "rm $filename"
, and then check that the file really was deleted for various values of $SHELL
and $filename
(and maybe even different locale settings to ensure correct behavior.
Unix paths are not necessarily UTF-8 so a generic way to escape them is useful. Overload
unix::escape
through private traitUnixEscape
so it can be used with bothCow<str>
andCow<[u8]>
.