talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 0931e06430de0b954b6a360f7785853a6b536a1c
parent 73746b23ffa18601bb0d18404b721511285f2133
Author: wwp <subscript@free.fr>
Date:   Thu, 19 Aug 2021 18:24:42 +0200

 fix_date.sh: document the fact coreutils, dos2unix, grep and sed are required,
fallback writing temporary files to $HOME if /tmp is not writable.

Diffstat:
Mtools/README | 3++-
Mtools/fix_date.sh | 25+++++++++++++++++++++----
2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/tools/README b/tools/README @@ -37,7 +37,8 @@ Other tools: Insert files into a new Compose window filter_conv_new.pl Convert new-style Sylpheed filters to filtering filter_conv.pl Convert old-style Sylpheed filters to filtering - fix-date.sh Replace/Add a message's Date field + fix_date.sh Replace/Add a message's Date field (coreutils, + dos2unix, grep and sed are required in PATH) mairix.sh A wrapper to mairix, to enable global searches in mail folders nautilus2claws-mail.sh Send files from Nautilus diff --git a/tools/fix_date.sh b/tools/fix_date.sh @@ -28,7 +28,7 @@ # TODO: fallback to X-OriginalArrivalTime: ? -VERSION="0.1.3" +VERSION="0.1.4" version() @@ -49,6 +49,8 @@ usage() echo " -r --rfc force re-writing of Date: header when it's not RFC-compliant" echo " -s --strict use RFC-strict matching patterns for dates" echo " -- end of switches (in case a filename starts with a -)" + echo "this script requires coreutils (cat, cut, head, tr), dos2unix, grep and set" + echo "in PATH to work" exit $1 } @@ -112,9 +114,24 @@ fi test $# -lt 1 && \ usage 1 -TMP="/tmp/${0##*/}.$$.tmp" -HEADERS="/tmp/${0##*/}.$$.headers.tmp" -BODY="/tmp/${0##*/}.$$.body.tmp" +for PROG in dos2unix grep sed +do + type "$PROG" >/dev/null 2>&1 || \ + { echo "error: $PROG not found in PATH"; exit 1; } +done + +TMPDIR="/tmp" +TMP="$TMPDIR/${0##*/}.$$.tmp" +echo > "$TMP" >/dev/null 2>&1 +if [ $? -eq 0 ] +then + rm -f "$TMP" >/dev/null 2>&1 +else + TMPDIR="$HOME" + TMP="$TMPDIR/${0##*/}.$$.tmp" +fi +HEADERS="$TMPDIR/${0##*/}.$$.headers.tmp" +BODY="$TMPDIR/${0##*/}.$$.body.tmp" DATE_REGEXP='( (Mon|Tue|Wed|Thu|Fri|Sat|Sun),)? [0-9]+ (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]+ [0-9]+:[0-9]+:[0-9]+ [+-]?[0-9]+' DATE_REGEXP_STRICT='(Mon|Tue|Wed|Thu|Fri|Sat|Sun), [0-9]+ (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]+ [0-9]+:[0-9]+:[0-9]+ [+-]?[0-9]+'