User: Password:
|
|
Subscribe / Log in / New account

Control characters in file names

Control characters in file names

Posted Nov 25, 2010 16:23 UTC (Thu) by Spudd86 (guest, #51683)
In reply to: Control characters in file names by nix
Parent article: Ghosts of Unix past, part 4: High-maintenance designs

Well part of the point is that such file names are hard to use, so hopefully you don't have any.

(They are the sort of names that make correctly handling file names in a shell script end up taking hundreds of lines, which means nobody EVER does it, which means pretty much nobody has files with that kind of name, except that the breakage from those names can sometimes be a security hole)


(Log in to post comments)

Control characters in file names

Posted Dec 2, 2010 19:07 UTC (Thu) by Ross (guest, #4065) [Link]

Why would it take hundreds of lines to handle them? Actually the shell doesn't so much care about control characters as characters found in $IFS which is space, tab, and newline by default. The proposal isn't to remove space, so it won't solve any problems for people writing shell scripts will it?

In any case, someone gave some examples of how to handle whitespace (and anything else) properly in shell scripts below. Use of arrays and proper quoting or find0/xargs0 combinations aren't too complicated and work correctly. The problem is that if there is a mistake, it won't be obvious since it will work with most input.

Control characters in file names

Posted Dec 2, 2010 19:44 UTC (Thu) by cesarb (subscriber, #6266) [Link]

If you remove control characters, you remove tab and newline; just set IFS to tab and newline (removing space) and you can easily and safely deal with filenames with spaces.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds