summaryrefslogtreecommitdiffstats
path: root/scripts/parts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/parts')
-rwxr-xr-xscripts/parts19
1 files changed, 15 insertions, 4 deletions
diff --git a/scripts/parts b/scripts/parts
index ae73c2f..6449a6e 100755
--- a/scripts/parts
+++ b/scripts/parts
@@ -66,10 +66,21 @@ add_part() {(
contentType="$(file -Lib "$filepath"); name=$filename"
case $contentType in
text/plain|text/plain\;*)
- contentTransferEncoding=8bit
- content() {
- cat "$filepath"
- }
+ max_length=$(awk '
+ length > max_length { max_length = length }
+ END { print max_length }
+ ')
+ if test "$max_length" -le 998; then
+ contentTransferEncoding=8bit
+ content() {
+ cat "$filepath"
+ }
+ else
+ contentTransferEncoding=base64
+ content() {
+ base64 "$filepath"
+ }
+ fi
;;
*)
contentTransferEncoding=base64