On 19-Mar-2009, at 04:45, Wietse Venema wrote:
$ ls -1 /usr/local/virtual/ | grep "@" | sed 's/^\([...@]*\)@\(.*\)$/
\/
^\1_\(.*\)@\2$\/ \1+$...@\2/'
testu...@example.com => /^testuser_(.*)@example.com$/ testuser+$...@example.com
This is BROKEN. You are not escaping any of the regexp metacharacters
such as '.' and so on.
All righty, I didn't escape the . but since exampleqcom or example$com
are not valid hostnames and the match is anchored to both the start
and end of the string AND since it is pulling the data from my own
list of existing users, I'm not seeing that it's much of a risk.
But sure, you can escape the . if you like, it only adds a few
characters to the sed portion.
sed 's/^\([...@]*\)@\([^.]*\)\.\(.*\)$/\/^\1_\(.*\)@\2\\.\3$\/ \1+${1}@
\2\\.\3/'
--
Well boys, we got three engines out, we got more holes in us than a
horse trader's mule, the radio is gone and we're leaking fuel
and if we was flying any lower why we'd need sleigh bells on
this thing... but we got one little budge on those Roosskies.
At this height why they might harpoon us but they dang sure
ain't gonna spot us on no radar screen!