| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 #--------------------------------------------- | 2 #--------------------------------------------- |
| 3 # xdg-email | 3 # xdg-email |
| 4 # | 4 # |
| 5 # Utility script to open the users favorite email program, using the | 5 # Utility script to open the users favorite email program, using the |
| 6 # RFC 2368 mailto: URI spec | 6 # RFC 2368 mailto: URI spec |
| 7 # | 7 # |
| 8 # Refer to the usage() function below for usage. | 8 # Refer to the usage() function below for usage. |
| 9 # | 9 # |
| 10 # Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org> |
| 11 # Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org> |
| 10 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at> | 12 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at> |
| 11 # Copyright 2006, Jeremy White <jwhite@codeweavers.com> | 13 # Copyright 2006, Jeremy White <jwhite@codeweavers.com> |
| 12 # | 14 # |
| 13 # LICENSE: | 15 # LICENSE: |
| 14 # | 16 # |
| 15 # Permission is hereby granted, free of charge, to any person obtaining a | 17 # Permission is hereby granted, free of charge, to any person obtaining a |
| 16 # copy of this software and associated documentation files (the "Software"), | 18 # copy of this software and associated documentation files (the "Software"), |
| 17 # to deal in the Software without restriction, including without limitation | 19 # to deal in the Software without restriction, including without limitation |
| 18 # the rights to use, copy, modify, merge, publish, distribute, sublicense, | 20 # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 19 # and/or sell copies of the Software, and to permit persons to whom the | 21 # and/or sell copies of the Software, and to permit persons to whom the |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 else | 391 else |
| 390 MAILTO=$(echo "$MAILTO" | sed 's/^/to=/' | sed 's/?/\&/') | 392 MAILTO=$(echo "$MAILTO" | sed 's/^/to=/' | sed 's/?/\&/') |
| 391 fi | 393 fi |
| 392 | 394 |
| 393 MAILTO=$(echo "$MAILTO" | sed 's/&/\n/g') | 395 MAILTO=$(echo "$MAILTO" | sed 's/&/\n/g') |
| 394 TO=$(echo "$MAILTO" | grep '^to=' | sed 's/^to=//' | awk '{ printf "%s,",$0
}') | 396 TO=$(echo "$MAILTO" | grep '^to=' | sed 's/^to=//' | awk '{ printf "%s,",$0
}') |
| 395 CC=$(echo "$MAILTO" | grep '^cc=' | sed 's/^cc=//' | awk '{ printf "%s,",$0
}') | 397 CC=$(echo "$MAILTO" | grep '^cc=' | sed 's/^cc=//' | awk '{ printf "%s,",$0
}') |
| 396 BCC=$(echo "$MAILTO" | grep '^bcc=' | sed 's/^bcc=//' | awk '{ printf "%s,",
$0 }') | 398 BCC=$(echo "$MAILTO" | grep '^bcc=' | sed 's/^bcc=//' | awk '{ printf "%s,",
$0 }') |
| 397 SUBJECT=$(echo "$MAILTO" | grep '^subject=' | tail -n 1) | 399 SUBJECT=$(echo "$MAILTO" | grep '^subject=' | tail -n 1) |
| 398 BODY=$(echo "$MAILTO" | grep '^body=' | tail -n 1) | 400 BODY=$(echo "$MAILTO" | grep '^body=' | tail -n 1) |
| 399 ATTACH=$(echo "$MAILTO" | sed 's/^attach=/\n\nfile:\/\//g' | awk '/^file:/ {
printf "%s,",$0 }') | 401 ATTACH=$(echo "$MAILTO" | sed 's/^attach=/\n\nfile:\/\//g' | awk '/^file:/ {
printf "%s,",$0 }' | sed 's/,$//') |
| 400 | 402 |
| 401 if [ -z "$TO" ] ; then | 403 if [ -z "$TO" ] ; then |
| 402 NEWMAILTO= | 404 NEWMAILTO= |
| 403 else | 405 else |
| 404 NEWMAILTO="to='$TO'" | 406 NEWMAILTO="to='$TO'" |
| 405 fi | 407 fi |
| 406 if [ -n "$CC" ] ; then | 408 if [ -n "$CC" ] ; then |
| 407 NEWMAILTO="${NEWMAILTO},cc='$CC'" | 409 NEWMAILTO="${NEWMAILTO},cc='$CC'" |
| 408 fi | 410 fi |
| 409 if [ -n "$BCC" ] ; then | 411 if [ -n "$BCC" ] ; then |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 linenr = 1 | 537 linenr = 1 |
| 536 } | 538 } |
| 537 { | 539 { |
| 538 if ( linenr++ != 1 ) { | 540 if ( linenr++ != 1 ) { |
| 539 e = e "%0D%0A" | 541 e = e "%0D%0A" |
| 540 } | 542 } |
| 541 for ( i=1; i<=length ($0); ++i ) { | 543 for ( i=1; i<=length ($0); ++i ) { |
| 542 c = substr ($0, i, 1) | 544 c = substr ($0, i, 1) |
| 543 if ( ord [c] > 127 ) { | 545 if ( ord [c] > 127 ) { |
| 544 e = e "%" sprintf("%02X", ord [c]) | 546 e = e "%" sprintf("%02X", ord [c]) |
| 545 } else if ( c ~ /[@a-zA-Z0-9.-\\/]/ ) { | 547 } else if ( c ~ /[@a-zA-Z0-9.-\\\/]/ ) { |
| 546 e = e c | 548 e = e c |
| 547 } else { | 549 } else { |
| 548 e = e "%" sprintf("%02X", ord [c]) | 550 e = e "%" sprintf("%02X", ord [c]) |
| 549 } | 551 } |
| 550 } | 552 } |
| 551 } | 553 } |
| 552 END { | 554 END { |
| 553 print e | 555 print e |
| 554 } | 556 } |
| 555 ') | 557 ') |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 ;; | 714 ;; |
| 713 | 715 |
| 714 generic) | 716 generic) |
| 715 open_generic "${mailto}" | 717 open_generic "${mailto}" |
| 716 ;; | 718 ;; |
| 717 | 719 |
| 718 *) | 720 *) |
| 719 exit_failure_operation_impossible "no method available for opening '${mailto
}'" | 721 exit_failure_operation_impossible "no method available for opening '${mailto
}'" |
| 720 ;; | 722 ;; |
| 721 esac | 723 esac |
| OLD | NEW |