diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2019-01-29 16:22:42 +0100 | 
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2019-01-29 16:22:42 +0100 | 
| commit | fda41e399edf12c65b177ffbb98bc511b8f6463a (patch) | |
| tree | a422821fd2b70a9125fa9301fb53f3bdca668e6a | |
| parent | c9473557656164985c638d1defcf03ff4cb0958e (diff) | |
Dispatch expansion for linus and bsd
| -rwxr-xr-x | makecolumns.sh | 17 | 
1 files 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 | |||
| 5 | export LC_ALL=C | 5 | export LC_ALL=C | 
| 6 | export PATH=${PATH}:`pwd`/bin/ | 6 | export PATH=${PATH}:`pwd`/bin/ | 
| 7 | 7 | ||
| 8 | unset FIND_E | ||
| 9 | case `uname -s` in | ||
| 10 | *BSD|Darwin) FIND_E="-E " | ||
| 11 | esac | ||
| 12 | |||
| 8 | main() { | 13 | main() { | 
| 9 | [ -f /usr/local/bin/el ] && EL=/usr/local/bin/el | 14 | [ -f /usr/local/bin/el ] && EL=/usr/local/bin/el | 
| 10 | [ -f `dirname $0`/../bin/el ] && EL=`dirname $0`/../bin/el | 15 | [ -f `dirname $0`/../bin/el ] && EL=`dirname $0`/../bin/el | 
| @@ -30,7 +35,7 @@ main() { | |||
| 30 | 35 | ||
| 31 | if [ -f "$1/phonebook.db" ]; then | 36 | if [ -f "$1/phonebook.db" ]; then | 
| 32 | handle_format_version_4 "${1}" | 37 | handle_format_version_4 "${1}" | 
| 33 | elif [ -f ${1}/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] ]; then | 38 | elif [ -f "${1}"/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] ]; then | 
| 34 | handle_format_version_3 "${1}" | 39 | handle_format_version_3 "${1}" | 
| 35 | elif [ -n "`find "${1}" -iname atb?dd00 -ls -quit`" ]; then | 40 | elif [ -n "`find "${1}" -iname atb?dd00 -ls -quit`" ]; then | 
| 36 | handle_format_version_2 "${1}" | 41 | handle_format_version_2 "${1}" | 
| @@ -165,13 +170,13 @@ handle_format_version_2() { | |||
| 165 | handle_format_version_3() { | 170 | handle_format_version_3() { | 
| 166 | echo "Working on $1. Detected pre-2004 Telefonbuch version." | 171 | echo "Working on $1. Detected pre-2004 Telefonbuch version." | 
| 167 | # Extract teiln.dat | 172 | # Extract teiln.dat | 
| 168 | do_decompress_version_3 "$1/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt]" "teiln.dat" | 173 | do_decompress_version_3 "$1"/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] "teiln.dat" | 
| 169 | 174 | ||
| 170 | # See how long each filename is | 175 | # See how long each filename is | 
| 171 | export filename_len=$(( `ls | head -n 1 | wc -c` - 1 )) | 176 | export filename_len=$(( `ls | head -n 1 | wc -c` - 1 )) | 
| 172 | 177 | ||
| 173 | # Get total amount of files, for reporting progress | 178 | # Get total amount of files, for reporting progress | 
| 174 | number_of_files=`find -E . -depth 1 -regex '^\./[0123456789]+' | wc -l` | 179 | number_of_files=`find ${FIND_E} . -depth 1 -regex '^\./[0123456789]+' | wc -l` | 
| 175 | 180 | ||
| 176 | # from 2000F on file 0+3*n is table, so make it default | 181 | # from 2000F on file 0+3*n is table, so make it default | 
| 177 | table_file=0; vname_file=2 | 182 | table_file=0; vname_file=2 | 
| @@ -224,7 +229,7 @@ handle_format_version_3() { | |||
| 224 | 229 | ||
| 225 | # wipe all temporary extracted files | 230 | # wipe all temporary extracted files | 
| 226 | printf "Cleaning up decompressed chunks ... " | 231 | printf "Cleaning up decompressed chunks ... " | 
| 227 | find -E . -depth 1 -regex '^\./[0123456789]+' -delete | 232 | find ${FIND_E} . -depth 1 -regex '^\./[0123456789]+' -delete | 
| 228 | printf "done.\n" | 233 | printf "done.\n" | 
| 229 | 234 | ||
| 230 | # rename our columns extracted from the table file | 235 | # rename our columns extracted from the table file | 
| @@ -251,7 +256,7 @@ handle_format_version_3() { | |||
| 251 | 256 | ||
| 252 | # If street names come in an extra file, extract | 257 | # If street names come in an extra file, extract | 
| 253 | # street names first | 258 | # street names first | 
| 254 | streets="$1/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt]" | 259 | streets="$1"/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt] | 
| 255 | [ -f ${streets} ] && do_processfile_version_3 ${streets} "street name" 99_Strassenname convert_zeros | 260 | [ -f ${streets} ] && do_processfile_version_3 ${streets} "street name" 99_Strassenname convert_zeros | 
| 256 | 261 | ||
| 257 | # extract street names if 07_unknown contains street indexes | 262 | # extract street names if 07_unknown contains street indexes | 
| @@ -272,7 +277,7 @@ handle_format_version_3() { | |||
| 272 | tidy_streetnames 07_Strasse | 277 | tidy_streetnames 07_Strasse | 
| 273 | fi | 278 | fi | 
| 274 | 279 | ||
| 275 | karto="$1/[Dd][Aa][Tt]/[Kk][Aa][Rr][Tt][Oo].[Dd][Aa][Tt]" | 280 | karto="$1"/[Dd][Aa][Tt]/[Kk][Aa][Rr][Tt][Oo].[Dd][Aa][Tt] | 
| 276 | if [ -f ${karto} ]; then | 281 | if [ -f ${karto} ]; then | 
| 277 | do_processfile_version_3 ${karto} "geo coordinates" 90_Geokoordinaten_hnr_raw | 282 | do_processfile_version_3 ${karto} "geo coordinates" 90_Geokoordinaten_hnr_raw | 
| 278 | 283 | ||
