From fda41e399edf12c65b177ffbb98bc511b8f6463a Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 29 Jan 2019 16:22:42 +0100 Subject: Dispatch expansion for linus and bsd --- makecolumns.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/makecolumns.sh b/makecolumns.sh index 4920550..b73dffe 100755 --- a/makecolumns.sh +++ b/makecolumns.sh @@ -5,6 +5,11 @@ export LC_CTYPE=C export LC_ALL=C export PATH=${PATH}:`pwd`/bin/ +unset FIND_E +case `uname -s` in + *BSD|Darwin) FIND_E="-E " +esac + main() { [ -f /usr/local/bin/el ] && EL=/usr/local/bin/el [ -f `dirname $0`/../bin/el ] && EL=`dirname $0`/../bin/el @@ -30,7 +35,7 @@ main() { if [ -f "$1/phonebook.db" ]; then handle_format_version_4 "${1}" - elif [ -f ${1}/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] ]; then + elif [ -f "${1}"/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] ]; then handle_format_version_3 "${1}" elif [ -n "`find "${1}" -iname atb?dd00 -ls -quit`" ]; then handle_format_version_2 "${1}" @@ -165,13 +170,13 @@ handle_format_version_2() { handle_format_version_3() { echo "Working on $1. Detected pre-2004 Telefonbuch version." # Extract teiln.dat - do_decompress_version_3 "$1/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt]" "teiln.dat" + do_decompress_version_3 "$1"/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] "teiln.dat" # See how long each filename is export filename_len=$(( `ls | head -n 1 | wc -c` - 1 )) # Get total amount of files, for reporting progress - number_of_files=`find -E . -depth 1 -regex '^\./[0123456789]+' | wc -l` + number_of_files=`find ${FIND_E} . -depth 1 -regex '^\./[0123456789]+' | wc -l` # from 2000F on file 0+3*n is table, so make it default table_file=0; vname_file=2 @@ -224,7 +229,7 @@ handle_format_version_3() { # wipe all temporary extracted files printf "Cleaning up decompressed chunks ... " - find -E . -depth 1 -regex '^\./[0123456789]+' -delete + find ${FIND_E} . -depth 1 -regex '^\./[0123456789]+' -delete printf "done.\n" # rename our columns extracted from the table file @@ -251,7 +256,7 @@ handle_format_version_3() { # If street names come in an extra file, extract # street names first - streets="$1/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt]" + streets="$1"/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt] [ -f ${streets} ] && do_processfile_version_3 ${streets} "street name" 99_Strassenname convert_zeros # extract street names if 07_unknown contains street indexes @@ -272,7 +277,7 @@ handle_format_version_3() { tidy_streetnames 07_Strasse fi - karto="$1/[Dd][Aa][Tt]/[Kk][Aa][Rr][Tt][Oo].[Dd][Aa][Tt]" + karto="$1"/[Dd][Aa][Tt]/[Kk][Aa][Rr][Tt][Oo].[Dd][Aa][Tt] if [ -f ${karto} ]; then do_processfile_version_3 ${karto} "geo coordinates" 90_Geokoordinaten_hnr_raw -- cgit v1.2.3