views:

58

answers:

5

PLEASE don't tell me why you think its a bad idea. Just tell me if its a workable idea.

I want to create files in a folder with names like the following:

[email protected]
[email protected]
[email protected]

Is there some fundamental incompatibility in the characters allowed in email addresses and those allowed by a unix system?

I will be having a bash script reading the file names, subtracting the ".eml" ending, converting it into the "correct" usable format and sending an email to the address.

A simple test showed that it saved the above as files called

asdf\@qwerty.com.eml
abc+def\@asdf.net.eml
abc_def\@sasdf.at.eml
+3  A: 

Short answer:

przemek@linux-634b:~/tmp/email> touch [email protected]
przemek@linux-634b:~/tmp/email> ls
[email protected]

Works perfectly;)

Long answer:

It depends on filesystem you're using. See Wikipedia entry which lists allowed characters in file names. Most UNIX file systems support all characters that can be included in e-mail addresses. Non-UNIX filesystems, such as FAT, however, may cause problems.

Note that your problems may come from improper escaping. Check how are you creating your files.

el.pescado
+7  A: 

The only characters not allowed in a *nix filename are \0 and /, neither of which is allowed in an email address anyways. How your shell may handle symbols is another matter.

Ignacio Vazquez-Abrams
+3  A: 

There are no characters disallowed in UNIX file names except / (directory separator) and ASCII 0 (string terminator), so there is no problem at a fundamental level.

Handling those file names in shell scripts is a different matter; it requires at least quoting every variable reference as "$FILENAME", and forgetting even one quotatino will create a very rare, insidious bug. (Also, many other utilities will fail on strange characters such as | or newline unless you consistently use the -0 option.)

So yes, technically your bad idea is workable :-)

Kilian Foth
Variables in shell scripts must always be quoted to prevent serious bugs. Shell scripts that assume that file names won't contain spaces, newlines, etc., are broken by design.
Philipp
'course they're broken. But the point is that they are broken *in an extremely unobvious and insidious way*, because you can miss the error until an actual strasnge character comes along. *That*, combined with the great likelihood of forgetting the quotes once in a while, is what makes the idea so bad.
Kilian Foth
I see what's wrong with `\n` -- most utilities in UNIX are line-oriented (and `\n` is not allowed in emails anyway).But what can be possibly wrong with `|`?
Roman Cheplyaka
A: 

There is no problem with such file names on systems which treat file names as blobs and allow all byte sequences, i.e. Linux. But they are not portable to systems which treat file names as Unicode strings and disallow certain characters (Windows) or transform file names (Mac OS X, canonical decomposition).

Philipp
+2  A: 

What was your "simple test"?

Typing abc and hitting tab? The bash autocompletion will add a \ before every special character. But this does not mean, it is stored with a \ in its name.

Use ls to see the true name.

JochenJung