Ignore:
Timestamp:
Oct 20, 2012, 4:08:52 PM (8 years ago)
Author:
sam
Message:

build: check for a decent version of sed (ie. not the shitty BSD one).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/build/check-source.sh

    r1995 r2036  
    2929info() { if [ "$quiet" != true ]; then echo "I: $1"; fi }
    3030
     31# Ensure the system tools do not attempt to perform multibyte conversions
     32export LANG=C
     33
    3134# Find out where the top directory is and go there
    3235top_srcdir="$(cd "$(dirname $0)"; cd ..; pwd)"
     
    3437
    3538# Check for working tools
    36 #if [ "$(echo foo | grep -c foo)" != 1 ]; then
    37 #    error "grep -c does not appear to work, cancelling"
    38 #    exit 0
    39 #fi
     39if [ "$(echo foo | grep -c foo)" != 1 ]; then
     40    error "grep -c does not appear to work, cancelling"
     41    exit 0
     42fi
     43
     44SED=sed
     45if gsed --version >/dev/null 2>&1; then
     46    SED=gsed
     47fi
     48if [ "$(echo 'x\x' | $SED 's/.*[^x\t]//')" != x ]; then
     49    error "sed does not appear to work, cancelling"
     50    exit 0
     51fi
     52
    4053if d2u -h >/dev/null 2>&1; then
    4154    d2u=d2u
     
    7487
    7588OIFS="$IFS"
    76 IFS=$'\n'
     89IFS='
     90'
    7791if [ "$repo" = git ]; then
    7892    FILES="`git ls-files`"
     
    119133
    120134          # Check for trailing spaces
    121           nspaces="$(LANG=C sed 's/.*[^ \t]//' "$file" | tr -cd '\t ' | wc -c)"
     135          nspaces="$($SED 's/.*[^ \t]//' "$file" | tr -cd '\t ' | wc -c)"
    122136          total_spaces="$(($total_spaces + $nspaces))"
    123137          if [ "$nspaces" -gt 0 ]; then
    124138              clean=false
    125139              if [ "$fix" = true ]; then
    126                   LANG=C sed -i 's/[[:space:]][[:space:]]*$//g' "$file"
     140                  $SED -i 's/[[:space:]][[:space:]]*$//g' "$file"
    127141                  info "$file has $nspaces trailing spaces"
    128142              else
     
    137151              clean=false
    138152              if [ "$fix" = true ]; then
    139                   LANG=C sed -i 's/\t/    /g' "$file"
     153                  $SED -i 's/\t/    /g' "$file"
    140154                  info "$file has $ntabs tabs"
    141155              else
Note: See TracChangeset for help on using the changeset viewer.