-
Notifications
You must be signed in to change notification settings - Fork 430
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
export & rm: correctly handle paths containing whitespace and quotes #1102
Conversation
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.
closes #1097
nice solution!
Hi @mrnerdhair the problem I see here is that |
Interesting; I'll see if I can't find a workaround. |
7e2e43b
to
75af46b
Compare
In order to reliably process paths with whitespace or quotes to xargs without using non-POSIX features, each character must be escaped. (Quoting will handle whitespace, but not filenames with quotes in them.)
I made it work on Alpine by using Also this fancy new solution now can't handle filenames containing newline characters, so I guess I'll just label people who use those kind of filenames as social deviants who inherently deserve to be shunned. |
In order to reliably process paths with whitespace or quotes to xargs without using non-POSIX features, each character must be escaped. (Quoting will handle whitespace, but not filenames with quotes in them.)
Also found some more xargs commands with the same issues in distrobox-rm; same solution, so I threw in another commit to address those as well. |
Thanks a lot @mrnerdhair ! ❤️ |
I ran into an issue when exporting. I mentioned it here: 89luca89#1097 (comment) I have reworked a small part of the code to utilize the `-0` option of `xargs`
In order to reliably handle paths with whitespace, quotes, or nonprintable characters,find
,xargs
, andgrep
should be configured to separate them using the NUL character rather than using newlines or ad-hoc escaping. (This is documented in the shellcheck linting rule SC2038, which documents a real issue and should not be disabled.)Update:
In order to reliably process paths with whitespace or quotes to xargs without using non-POSIX features, each character must be escaped. (Quoting will handle whitespace, but not filenames with quotes in them.)