views:

272

answers:

3

When building an application with a CLI, it is useful to avoid using tokens that are commonly used for shell features.

For example, | is used for piping output of one application to input of the next.

Please supply a complete list of tokens that would need to be escaped to be used?

As a minimum/summary, for each token, please identify the applicable OS/shell(s), a simple explanation of what the token does, and any escape methods.

(Other useful information is welcome, once the above is clear.)

+2  A: 

What about starting with Unix ones

Fernando Miguélez
+1  A: 

Fernando Miguélez has given you an excellent source of information. It is almost easier to stipulate which characters do not have a special meaning. That list would be:

A-Z a-z 0-9 _ - . , / + @

Any other ASCII punctuation character has some special significance, somewhere. Some members of that list have special significance in combination with another character; for example, '$@' and '$-' are both special, but the '$' tells you that, rather than the '@' or '-'.

Jonathan Leffler
What about '=', '%' and ':'?
Jonathan Leffler
+1  A: 

On Windows and MS-DOS systems, the following are invalid filenames:

CON, PRN, AUX, CLOCK$, NUL
COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9
LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9

In the rare cases where you can work around this restriction and create such files, you will encounter problems trying to access or view them.

Sparr