jpayne@68: #!/bin/sh jpayne@68: # Prints the user's email address, with confirmation from the user. jpayne@68: # jpayne@68: # Copyright (C) 2001-2003, 2005, 2013 Free Software Foundation, Inc. jpayne@68: # jpayne@68: # This program is free software: you can redistribute it and/or modify jpayne@68: # it under the terms of the GNU General Public License as published by jpayne@68: # the Free Software Foundation; either version 3 of the License, or jpayne@68: # (at your option) any later version. jpayne@68: # jpayne@68: # This program is distributed in the hope that it will be useful, jpayne@68: # but WITHOUT ANY WARRANTY; without even the implied warranty of jpayne@68: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jpayne@68: # GNU General Public License for more details. jpayne@68: # jpayne@68: # You should have received a copy of the GNU General Public License jpayne@68: # along with this program. If not, see . jpayne@68: jpayne@68: # Prerequisites for using ${exec_prefix}/lib and ${datarootdir}/locale. jpayne@68: prefix="/mnt/c/Users/crash/Documents/BobLiterman/CSP2_Galaxy/CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce" jpayne@68: exec_prefix="${prefix}" jpayne@68: datarootdir="${prefix}/share" jpayne@68: datadir="${datarootdir}" jpayne@68: # Set variables libdir, localedir. jpayne@68: libdir="${exec_prefix}/lib" jpayne@68: localedir="${datarootdir}/locale" jpayne@68: jpayne@68: # Support for relocatability. jpayne@68: if test "no" = yes; then jpayne@68: orig_installdir="$libdir"/gettext # see Makefile.am's install rule jpayne@68: # Determine curr_installdir without caring for symlinked callers. jpayne@68: curr_installdir=`echo "$0" | sed -e 's,/[^/]*$,,'` jpayne@68: curr_installdir=`cd "$curr_installdir" && pwd` jpayne@68: # Compute the original/current installation prefixes by stripping the jpayne@68: # trailing directories off the original/current installation directories. jpayne@68: while true; do jpayne@68: orig_last=`echo "$orig_installdir" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` jpayne@68: curr_last=`echo "$curr_installdir" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` jpayne@68: if test -z "$orig_last" || test -z "$curr_last"; then jpayne@68: break jpayne@68: fi jpayne@68: if test "$orig_last" != "$curr_last"; then jpayne@68: break jpayne@68: fi jpayne@68: orig_installdir=`echo "$orig_installdir" | sed -e 's,/[^/]*$,,'` jpayne@68: curr_installdir=`echo "$curr_installdir" | sed -e 's,/[^/]*$,,'` jpayne@68: done jpayne@68: # Now relocate the directory variables that we use. jpayne@68: libdir=`echo "$libdir/" | sed -e "s%^${orig_installdir}/%${curr_installdir}/%" | sed -e 's,/$,,'` jpayne@68: localedir=`echo "$localedir/" | sed -e "s%^${orig_installdir}/%${curr_installdir}/%" | sed -e 's,/$,,'` jpayne@68: fi jpayne@68: jpayne@68: # Internationalization. jpayne@68: . gettext.sh jpayne@68: TEXTDOMAIN=gettext-tools jpayne@68: export TEXTDOMAIN jpayne@68: TEXTDOMAINDIR="$localedir" jpayne@68: export TEXTDOMAINDIR jpayne@68: jpayne@68: # Redirect fileno 3 to interactive I/O. jpayne@68: exec 3>/dev/tty jpayne@68: jpayne@68: # Output a prompt. jpayne@68: if test $# != 0; then jpayne@68: echo "$1" 1>&3 jpayne@68: fi jpayne@68: jpayne@68: # Find the user name on the local machine. jpayne@68: user=`id -u -n 2>/dev/null` jpayne@68: if test -z "$user"; then jpayne@68: user="$USER" jpayne@68: if test -z "$user"; then jpayne@68: user="$LOGNAME" jpayne@68: if test -z "$user"; then jpayne@68: user=unknown jpayne@68: fi jpayne@68: fi jpayne@68: fi jpayne@68: jpayne@68: # Find the hostname. jpayne@68: # hostname on some systems (SVR3.2, old Linux) returns a bogus exit status, jpayne@68: # so uname gets run too, so we keep only the first line of output. jpayne@68: #host=`(hostname || uname -n) 2>/dev/null | sed 1q` jpayne@68: host=`"$libdir"/gettext/hostname --short 2>/dev/null | sed 1q` jpayne@68: jpayne@68: # Find the hostname. jpayne@68: hostfqdn=`"$libdir"/gettext/hostname --fqdn 2>/dev/null | sed 1q` jpayne@68: jpayne@68: # Find a list of email addresses from various mailer configuration files. jpayne@68: # All mailers use configuration files under $HOME. We handle them in a jpayne@68: # last-modified - first-priority order. jpayne@68: cd $HOME jpayne@68: files="" jpayne@68: jpayne@68: # ----------------------- BEGIN MAILER SPECIFIC CODE ----------------------- jpayne@68: jpayne@68: # Mozilla Thunderbird addresses jpayne@68: files="$files .thunderbird/*/prefs.js" jpayne@68: jpayne@68: # Mozilla addresses jpayne@68: files="$files .mozilla/*/prefs.js" jpayne@68: jpayne@68: # Netscape 4 addresses jpayne@68: files="$files .netscape/liprefs.js .netscape/preferences.js" jpayne@68: jpayne@68: # Netscape 3 addresses jpayne@68: files="$files .netscape/preferences" jpayne@68: jpayne@68: # Emacs/XEmacs rmail, Emacs/XEmacs gnus, XEmacs vm addresses jpayne@68: # XEmacs mew addresses jpayne@68: files="$files .emacs .emacs.el" jpayne@68: jpayne@68: # KDE2 addresses jpayne@68: files="$files .kde2/share/config/emaildefaults" jpayne@68: jpayne@68: # KDE kmail addresses jpayne@68: files="$files .kde2/share/config/kmailrc" jpayne@68: jpayne@68: # GNOME evolution 2 addresses jpayne@68: files="$files .gconf/apps/evolution/mail/%gconf.xml" jpayne@68: jpayne@68: # GNOME evolution 1 addresses jpayne@68: files="$files evolution/config.xmldb" jpayne@68: jpayne@68: # GNOME balsa addresses jpayne@68: files="$files .gnome/balsa" jpayne@68: jpayne@68: # StarOffice and OpenOffice addresses jpayne@68: sed_dos2unix='s/\r$//' jpayne@68: sed_soffice51='s,StarOffice 5\.1=\(.*\)$,\1/sofficerc,p' jpayne@68: sed_soffice52='s,StarOffice 5\.2=\(.*\)$,\1/user/sofficerc,p' jpayne@68: sed_ooffice='s,^OpenOffice[^=]*=\(.*\)$,\1/user/config/registry/instance/org/openoffice/UserProfile.xml,p' jpayne@68: files="$files Office51/sofficerc Office52/user/sofficerc "`sed -n -e "$sed_dos2unix" -e "$sed_soffice51" -e "$sed_soffice52" -e "$sed_ooffice" .sversionrc 2>/dev/null | sed -e 's,^file://*,/,'` jpayne@68: jpayne@68: # mutt addresses jpayne@68: files="$files .muttrc" jpayne@68: jpayne@68: # pine addresses jpayne@68: files="$files .pinerc" jpayne@68: jpayne@68: # xfmail addresses jpayne@68: files="$files .xfmail/.xfmailrc" jpayne@68: jpayne@68: # tkrat addresses jpayne@68: files="$files .ratatosk/ratatoskrc" jpayne@68: jpayne@68: # ----------------------- END MAILER SPECIFIC CODE ----------------------- jpayne@68: jpayne@68: # Expand wildcards and remove nonexistent files from the list. jpayne@68: nfiles="" jpayne@68: for file in $files; do jpayne@68: if test -r "$file" && test ! -d "$file"; then jpayne@68: nfiles="$nfiles $file" jpayne@68: fi jpayne@68: done jpayne@68: files="$nfiles" jpayne@68: jpayne@68: addresses="" jpayne@68: jpayne@68: if test -n "$files"; then jpayne@68: jpayne@68: for file in `ls -t $files`; do jpayne@68: jpayne@68: case "$file" in jpayne@68: jpayne@68: # ----------------------- BEGIN MAILER SPECIFIC CODE ----------------------- jpayne@68: jpayne@68: # Mozilla and Mozilla Thunderbird addresses jpayne@68: .mozilla/*/prefs.js | .thunderbird/*/prefs.js) jpayne@68: addresses="$addresses "`grep -h '^user_pref("mail\.identity\..*\.useremail", ".*");$' $file 2>/dev/null | sed -e 's/^user_pref("mail\.identity\..*\.useremail", "\(.*\)");$/\1/'` jpayne@68: ;; jpayne@68: jpayne@68: # Netscape 4 addresses jpayne@68: .netscape/liprefs.js | .netscape/preferences.js) jpayne@68: addresses="$addresses "`grep -h '^user_pref("mail\.identity\.useremail", ".*");$' $file 2>/dev/null | sed -e 's/^user_pref("mail\.identity\.useremail", "\(.*\)");$/\1/'` jpayne@68: ;; jpayne@68: jpayne@68: # Netscape 3 addresses jpayne@68: .netscape/preferences) jpayne@68: addresses="$addresses "`grep -h '^EMAIL_ADDRESS:' $file 2>/dev/null | sed -e 's/^EMAIL_ADDRESS:[ ]*//'` jpayne@68: ;; jpayne@68: jpayne@68: .emacs | .emacs.el) jpayne@68: # Emacs/XEmacs rmail, Emacs/XEmacs gnus, XEmacs vm addresses jpayne@68: addresses="$addresses "`grep -h '[ (]user-mail-address "[^"]*"' $file 2>/dev/null | sed -e 's/^.*[ (]user-mail-address "\([^"]*\)".*$/\1/'` jpayne@68: # XEmacs mew addresses jpayne@68: domains=`grep -h '[ (]mew-mail-domain "[^"]*"' $file 2>/dev/null | sed -e 's/^.*[ (]mew-mail-domain "\([^"]*\)".*$/\1/'` jpayne@68: if test -n "$domains"; then jpayne@68: for domain in $domains; do jpayne@68: addresses="$addresses ${user}@$domain" jpayne@68: done jpayne@68: fi jpayne@68: ;; jpayne@68: jpayne@68: # KDE2 addresses jpayne@68: .kde2/share/config/emaildefaults) jpayne@68: addresses="$addresses "`grep -h '^EmailAddress=' $file 2>/dev/null | sed -e 's/^EmailAddress=//'` jpayne@68: ;; jpayne@68: jpayne@68: # KDE kmail addresses jpayne@68: .kde2/share/config/kmailrc) jpayne@68: addresses="$addresses "`grep -h '^Email Address=' $file 2>/dev/null | sed -e 's/^Email Address=//'` jpayne@68: ;; jpayne@68: jpayne@68: # GNOME evolution 2 addresses jpayne@68: .gconf/apps/evolution/mail/%gconf.xml) jpayne@68: sedexpr0='s,^.*<addr-spec>\(.*\)</addr-spec>.*$,\1,p' jpayne@68: addresses="$addresses "`sed -n -e "$sedexpr0" < $file` jpayne@68: ;; jpayne@68: jpayne@68: # GNOME evolution 1 addresses jpayne@68: evolution/config.xmldb) jpayne@68: sedexpr0='s/^.*\(.*\).*$,\1,p' $file 2>/dev/null` jpayne@68: ;; jpayne@68: jpayne@68: # StarOffice addresses jpayne@68: # Not a typo. They really write "Adress" with a single d. jpayne@68: # German orthography... jpayne@68: */sofficerc) jpayne@68: addresses="$addresses "`grep -h '^User-Adress=' $file 2>/dev/null | sed -e 's/#[^#]*$//' -e 's/^.*#//'` jpayne@68: ;; jpayne@68: jpayne@68: # mutt addresses jpayne@68: .muttrc) jpayne@68: mutt_addresses=`grep -h '^set from="[^"]*"[ ]*$' $file 2>/dev/null | sed -e 's/^set from="\([^"]*\)"[ ]*$/\1/'` jpayne@68: if test -n "$mutt_addresses"; then jpayne@68: addresses="$addresses $mutt_addresses" jpayne@68: else jpayne@68: # mutt uses $EMAIL as fallback. jpayne@68: if test -n "$EMAIL"; then jpayne@68: addresses="$addresses $EMAIL" jpayne@68: fi jpayne@68: fi jpayne@68: ;; jpayne@68: jpayne@68: # pine addresses jpayne@68: .pinerc) jpayne@68: domains=`grep -h '^user-domain=' $file 2>/dev/null | sed -e 's/^user-domain=//'` jpayne@68: if test -n "$domains"; then jpayne@68: for domain in $domains; do jpayne@68: addresses="$addresses ${user}@$domain" jpayne@68: done jpayne@68: else jpayne@68: # The use-only-domain-name option is only used if the user-domain option is not present. jpayne@68: domains=`grep -h '^use-only-domain-name=' $file 2>/dev/null | sed -e 's/^use-only-domain-name=//'` jpayne@68: if test "Yes" = "$domains"; then jpayne@68: addresses="$addresses ${user}@"`echo "$hostfqdn" | sed -e 's/^[^.]*\.//'` jpayne@68: fi jpayne@68: fi jpayne@68: ;; jpayne@68: jpayne@68: # xfmail addresses jpayne@68: .xfmail/.xfmailrc) jpayne@68: addresses="$addresses "`grep -h '^from=.*<.*>' $file 2>/dev/null | sed -e 's/^.*<\([^<>]*\)>.*$/\1/'` jpayne@68: ;; jpayne@68: jpayne@68: # tkrat addresses jpayne@68: .ratatosk/ratatoskrc) jpayne@68: domains=`grep -h '^set option(masquerade_as) ' $file 2>/dev/null | sed -e 's/^set option(masquerade_as) //'` jpayne@68: if test -n "$domains"; then jpayne@68: for domain in $domains; do jpayne@68: addresses="$addresses ${user}@$domain" jpayne@68: done jpayne@68: else jpayne@68: # The domain option is used only if the masquerade_as option is not present. jpayne@68: domains=`grep -h '^set option(domain) ' $file 2>/dev/null | sed -e 's/^set option(domain) //'` jpayne@68: if test -n "$domains"; then jpayne@68: for domain in $domains; do jpayne@68: addresses="$addresses ${user}@${host}.$domain" jpayne@68: done jpayne@68: fi jpayne@68: fi jpayne@68: ;; jpayne@68: jpayne@68: # ----------------------- END MAILER SPECIFIC CODE ----------------------- jpayne@68: jpayne@68: esac jpayne@68: jpayne@68: done jpayne@68: jpayne@68: fi jpayne@68: jpayne@68: # Some Debian systems have a file /etc/mailname. jpayne@68: if test -r /etc/mailname; then jpayne@68: hostmailname=`cat /etc/mailname` jpayne@68: if test -n "$hostmailname"; then jpayne@68: addresses="$addresses ${user}@$hostmailname" jpayne@68: fi jpayne@68: fi jpayne@68: jpayne@68: # SuSE Linux >= 8.0 systems have a file /etc/sysconfig/mail. jpayne@68: if test -r /etc/sysconfig/mail; then jpayne@68: hostmailname=`. /etc/sysconfig/mail && echo "$FROM_HEADER"` jpayne@68: if test -n "$hostmailname"; then jpayne@68: addresses="$addresses ${user}@$hostmailname" jpayne@68: fi jpayne@68: fi jpayne@68: jpayne@68: # elm has no user-defined addresses. jpayne@68: # mailx has no user-defined addresses. jpayne@68: # mh has no user-defined addresses. jpayne@68: # They use the system default. jpayne@68: addresses="$addresses ${user}@$hostfqdn" jpayne@68: jpayne@68: # Normalize addresses: remove addresses without @, lowercase the part after @, jpayne@68: # and remove duplicates. jpayne@68: lowercase_sed='{ jpayne@68: h jpayne@68: s/^[^@]*@\(.*\)$/\1/ jpayne@68: y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ jpayne@68: x jpayne@68: s/^\([^@]*\)@.*/\1@/ jpayne@68: G jpayne@68: s/\n// jpayne@68: p jpayne@68: }' jpayne@68: naddresses="" jpayne@68: for addr in $addresses; do jpayne@68: case "$addr" in jpayne@68: "<"*">") addr=`echo "$addr" | sed -e 's/^$//'` ;; jpayne@68: esac jpayne@68: case "$addr" in jpayne@68: *@*) jpayne@68: addr=`echo "$addr" | sed -n -e "$lowercase_sed"` jpayne@68: case " $naddresses " in jpayne@68: *" $addr "*) ;; jpayne@68: *) naddresses="$naddresses $addr" ;; jpayne@68: esac jpayne@68: ;; jpayne@68: esac jpayne@68: done jpayne@68: addresses="$naddresses" jpayne@68: jpayne@68: # Now it's time to ask the user. jpayne@68: case "$addresses" in jpayne@68: " "*" "*) jpayne@68: # At least two addresses. jpayne@68: lines="" jpayne@68: i=0 jpayne@68: for addr in $addresses; do jpayne@68: i=`expr $i + 1` jpayne@68: lines="${lines}${i} ${addr} jpayne@68: " jpayne@68: done jpayne@68: while true; do jpayne@68: { gettext "Which is your email address?"; echo; } 1>&3 jpayne@68: echo "$lines" 1>&3 jpayne@68: { gettext "Please choose the number, or enter your email address."; echo; } 1>&3 jpayne@68: read answer < /dev/tty jpayne@68: case "$answer" in jpayne@68: *@*) ;; jpayne@68: [0-9]*) jpayne@68: i=0 jpayne@68: for addr in $addresses; do jpayne@68: i=`expr $i + 1` jpayne@68: if test "$i" = "$answer"; then jpayne@68: break 2 jpayne@68: fi jpayne@68: done jpayne@68: ;; jpayne@68: esac jpayne@68: case "$answer" in jpayne@68: "<"*">") answer=`echo "$answer" | sed -e 's/^$//'` ;; jpayne@68: esac jpayne@68: case "$answer" in jpayne@68: *" "*) { gettext "Invalid email address: invalid character."; echo; echo; } 1>&3 ; continue ;; jpayne@68: *@*.*) ;; jpayne@68: *@*) { gettext "Invalid email address: need a fully qualified host name or domain name."; echo; echo; } 1>&3 ; continue ;; jpayne@68: *) { gettext "Invalid email address: missing @"; echo; echo; } 1>&3 ; continue ;; jpayne@68: esac jpayne@68: addr=`echo "$answer" | sed -n -e "$lowercase_sed"` jpayne@68: break jpayne@68: done jpayne@68: ;; jpayne@68: " "*) jpayne@68: # One address. jpayne@68: while true; do jpayne@68: { gettext "Is the following your email address?"; echo; } 1>&3 jpayne@68: echo " $addresses" 1>&3 jpayne@68: { gettext "Please confirm by pressing Return, or enter your email address."; echo; } 1>&3 jpayne@68: read answer < /dev/tty jpayne@68: if test -z "$answer"; then jpayne@68: addr=`echo "$addresses" | sed -e 's/^ //'` jpayne@68: break jpayne@68: fi jpayne@68: case "$answer" in jpayne@68: "<"*">") answer=`echo "$answer" | sed -e 's/^$//'` ;; jpayne@68: esac jpayne@68: case "$answer" in jpayne@68: *" "*) { gettext "Invalid email address: invalid character."; echo; echo; } 1>&3 ; continue ;; jpayne@68: *@*.*) ;; jpayne@68: *@*) { gettext "Invalid email address: need a fully qualified host name or domain name."; echo; echo; } 1>&3 ; continue ;; jpayne@68: *) { gettext "Invalid email address: missing @"; echo; echo; } 1>&3 ; continue ;; jpayne@68: esac jpayne@68: addr=`echo "$answer" | sed -n -e "$lowercase_sed"` jpayne@68: break jpayne@68: done jpayne@68: ;; jpayne@68: "") jpayne@68: # No address. jpayne@68: { gettext "Couldn't find out about your email address."; echo; } 1>&3 jpayne@68: while true; do jpayne@68: { gettext "Please enter your email address."; echo; } 1>&3 jpayne@68: read answer < /dev/tty jpayne@68: case "$answer" in jpayne@68: "<"*">") answer=`echo "$answer" | sed -e 's/^$//'` ;; jpayne@68: esac jpayne@68: case "$answer" in jpayne@68: *" "*) { gettext "Invalid email address: invalid character."; echo; echo; } 1>&3 ; continue ;; jpayne@68: *@*.*) ;; jpayne@68: *@*) { gettext "Invalid email address: need a fully qualified host name or domain name."; echo; echo; } 1>&3 ; continue ;; jpayne@68: *) { gettext "Invalid email address: missing @"; echo; echo; } 1>&3 ; continue ;; jpayne@68: esac jpayne@68: addr=`echo "$answer" | sed -n -e "$lowercase_sed"` jpayne@68: break jpayne@68: done jpayne@68: ;; jpayne@68: *) echo "internal error" 1>&3 ; exit 1 ;; jpayne@68: esac jpayne@68: jpayne@68: # Print to standard output. jpayne@68: echo "$addr"