Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sed complain about [[:space:]], not [:space:] #9

Closed
szorfein opened this issue Feb 13, 2017 · 6 comments
Closed

sed complain about [[:space:]], not [:space:] #9

szorfein opened this issue Feb 13, 2017 · 6 comments

Comments

@szorfein
Copy link

hi, i try debuggin your script because it seem don't work on recent version of bash...look this part.
( this is just a minimal version of your script for debuggin )

#! /bin/bash

TMPDIR="/tmp/privoxy"
URLS=  ("https://raw.githubusercontent.com/easylist/easylist/master/easyprivacy/easyprivacy_thirdparty.txt")

if [[ ! -d $TMPDIR ]] ; then
    echo "mkdir $TMPDIR"
    install -d -m700 $TMPDIR
fi

for url in ${URLS[@]}
do
    echo "Processing ${url} ...\n" || exit 0
    file=${TMPDIR}/$(basename ${url})
    actionfile=${file%\.*}.script.action
    filterfile=${file%\.*}.script.filter
    list=$(basename ${file%\.*})

    echo "Downloading ${url} ..." || exit 0
    wget -t 3 -O $file $url
    echo ".. downloading done." || exit 0

    echo "Creating actionfile for $list" || exit 1
    echo -e "{ +block{${list}} }" > "${actionfile}"
    sed '/^!.*/d;1,1 d;/^@@.*/d;/\$.*/d;/#/d;s/\./\\./g;s|?|\\?|g;s/\*/.*/g;s/(/\\(/g;s/)/\\)/g;s/\[/\\[/g;s/\]/\\]/g;s/\^/[\/\&:\?=_]/g;s/^||/\./g;s/^|/^/g;s/|$/\$/g;/|/d' ${file} >> ${actionfile}
    echo "actionfile -> $actionfile done"

    echo "Creating filterfile for $list..." || exit 1
    echo "FILTER: ${list} Tag filter of ${list}" > "${filterfile}"

   # this bug here <This sed command doesn't work>
   sed '/^#/!d;s/^##//g;s/^#\(.*\)\[.*\]\[.*\]*/s@<([a-zA-Z0-9]+)\\s+.*id=.?\1.*>.*<\/\\1>@@g/g;s/^#\(.*\)/s@<([a-zA-Z0-9]+)\\s+.*id=.?\1.*>.*<\/\\1>@@g/g;s/^\.\(.*\)/s@<([a-zA-Z0-9]+)\\s+.*class=.?\1.*>.*<\/\\1>@@g/g;s/^a\[\(.*\)\]/s@<a.*\1.*>.*<\/a>@@g/g;s/^\([a-zA-Z0-9]*\)\.\(.*\)\[.*\]\[.*\]*/s@<\1.*class=.?\2.*>.*<\/\1>@@g/g;s/^\([a-zA-Z0-9]*\)#\(.*\):.*[:[^:]]*[^:]*/s@<\1.*id=.?\2.*>.*<\/\1>@@g/g;s/^\([a-zA-Z0-9]*\)#\(.*\)/s@<\1.*id=.?\2.*>.*<\/\1>@@g/g;s/^\[\([a-zA-Z]*\).=\(.*\)\]/s@\1^=\2>@@g/g;s/\^/[\/\&:\?=_]/g;s/\.\([a-zA-Z0-9]\)/\\.\1/g' ${file} >> ${filterfile}

    echo "{ +filter{${list}} }" >> "${actionfile}"
    echo "*" >> ${actionfile}
    echo "... filterfile added ..." || exit 1

done

The error -> sed: character class syntax is [[:space:]], not [:space:]

@Bernd-Osterhage
Copy link

It seems that there is an escape char in front of the first ":" missing!
Original part: *[:[^:]]*[^:]*
Changed part: *[\:[^:]]*[^:]*

@szorfein
Copy link
Author

thanks, it seem to work.

@EnricoVerzegnassi
Copy link

It works! Thans 👍

@bastiandoetsch
Copy link

Works for me, too.

@mkaand
Copy link

mkaand commented Jan 19, 2020

Thanks man. I recently upgraded my server from Ubuntu 16.04 to 18.04 and I start receiving errors for this script (same error) I fixed with your solution. I guess bash version changed after upgrade. That's why script failed.

@Andrwe
Copy link
Owner

Andrwe commented Jan 8, 2022

merged into master with #14

@Andrwe Andrwe closed this as completed Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants