Skip to content

overload unix::escape to be useable with Cow<[u8]>#4

Open
fbenkstein wants to merge 4 commits into
sfackler:masterfrom
fbenkstein:u8-escape
Open

overload unix::escape to be useable with Cow<[u8]>#4
fbenkstein wants to merge 4 commits into
sfackler:masterfrom
fbenkstein:u8-escape

Conversation

@fbenkstein

Copy link
Copy Markdown

Unix paths are not necessarily UTF-8 so a generic way to escape them is useful. Overload unix::escape through private trait UnixEscape so it can be used with both Cow<str> and Cow<[u8]>.

@fbenkstein

Copy link
Copy Markdown
Author

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.

@sfackler

Copy link
Copy Markdown
Owner

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?

@fbenkstein

fbenkstein commented Apr 1, 2018 via email

Copy link
Copy Markdown
Author

@fbenkstein

Copy link
Copy Markdown
Author

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.

@fbenkstein

fbenkstein commented Apr 4, 2018

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants