..........snip............
EDIT
Nevermind , I figured out problem myself in the meantime , Cannot delete post.
MountainX wrote:skanky wrote:Something is messing up the sed instruction so that it doesn't find the end / (nor the g if there is one). This could be down to a ' in an embedded variable?
Is that code the actual code, or has it been changed?I copied and pasted directly from the post above (the post I quoted). I did not change anything. When I got the error, I copied and pasted again. Same error. Then I went to one of the other posts in this thread that has a modified version of the script. It gave me the same error, but at a different line number.
Nobody else is getting the error?
I'm running the script in bash on Arch with all packages up to date.
It may be something that your browser/editor is doing with the copied text? Can you manually check the code in the sed call and/or look for non-displaying chars. I haven't tried running this code in ages (been meaning to switch back to give it a try), but when I did I didn't get the error.
I've been doing my best to figure out the problem but so far I am still getting the error. I'm reading this forum with Firefox and I'm using kate and/or nano to edit (tried both). All I'm doing is copy/paste. My pasted code looks exactly like what I'm reading on the forum. I don't see any obvious copy/paste errors.
]]>skanky wrote:Something is messing up the sed instruction so that it doesn't find the end / (nor the g if there is one). This could be down to a ' in an embedded variable?
Is that code the actual code, or has it been changed?I copied and pasted directly from the post above (the post I quoted). I did not change anything. When I got the error, I copied and pasted again. Same error. Then I went to one of the other posts in this thread that has a modified version of the script. It gave me the same error, but at a different line number.
Nobody else is getting the error?
I'm running the script in bash on Arch with all packages up to date.
It may be something that your browser/editor is doing with the copied text? Can you manually check the code in the sed call and/or look for non-displaying chars. I haven't tried running this code in ages (been meaning to switch back to give it a try), but when I did I didn't get the error.
]]>Nobody else is getting the error?
I copy & paste from your post #26 and got not your error. But the hint that the news are moved to https
]]>Something is messing up the sed instruction so that it doesn't find the end / (nor the g if there is one). This could be down to a ' in an embedded variable?
Is that code the actual code, or has it been changed?
I copied and pasted directly from the post above (the post I quoted). I did not change anything. When I got the error, I copied and pasted again. Same error. Then I went to one of the other posts in this thread that has a modified version of the script. It gave me the same error, but at a different line number.
Nobody else is getting the error?
I'm running the script in bash on Arch with all packages up to date.
]]>skanky wrote:Right, this worked for me:
Great!
This is the script with your suggestions:#!/bin/bash if [ ! -n "$FEED_BOOKMARKS" ]; then export FEED_BOOKMARKS=$HOME/.feed_bookmarks; fi if [ ! -d "$FEED_BOOKMARKS" ]; then mkdir -p $FEED_BOOKMARKS; fi feed() { if [ ! -d $FEED_BOOKMARKS ]; then mkdir $FEED_BOOKMARKS; fi if [ ! -n "$1" ]; then echo -e "\\n \\e[04mUsage\\e[00m\\n\\n \\e[01;37m\$ feed \\e[01;31m<url>\\e[00m \\e[01;31m<new bookmark?>\\e[00m\\n\\n \\e[04mSee also\\e[00m\\n\\n \\e[01;37m\$ deef\\e[00m\\n" return 1; fi local rss_source="$(curl --silent $1 | sed -e ':a;N;$!ba;s/\n/ /g')"; if [ ! -n "$rss_source" ]; then echo "The feed is empty"; return 1; fi # THE RSS PARSER # The characters "£, §" are used as metacharacters. They should not be encountered in a feed... echo -e "$(echo $rss_source | \ sed -e 's/&/\&/g s/<\|</</g s/>\|>/>/g s/<\/a>/£/g s/href\=\"/§/g s/<title>/\\n\\n\\n :: \\e[01;31m/g; s/<\/title>/\\e[00m ::\\n/g s/<link>/ [ \\e[01;36m/g; s/<\/link>/\\e[00m ]/g s/<description>/\\n\\n\\e[00;37m/g; s/<\/description>/\\e[00m\\n\\n/g s/<p\( [^>]*\)\?>\|<br\s*\/\?>/\n/g s/<b\( [^>]*\)\?>\|<strong\( [^>]*\)\?>/\\e[01;30m/g; s/<\/b>\|<\/strong>/\\e[00;37m/g s/<i\( [^>]*\)\?>\|<em\( [^>]*\)\?>/\\e[41;37m/g; s/<\/i>\|<\/em>/\\e[00;37m/g s/<u\( [^>]*\)\?>/\\e[4;37m/g; s/<\/u>/\\e[00;37m/g s/<code\( [^>]*\)\?>/\\e[00m/g; s/<\/code>/\\e[00;37m/g s/<a[^§]*§\([^\"]*\)\"[^>]*>\([^£]*\)[^£]*£/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g s/<li\( [^>]*\)\?>/\n \\e[01;34m*\\e[00;37m /g s/<!\[CDATA\[\|\]\]>//g s/\|>\s*<//g s/ *<[^>]\+> */ /g s/[<>£§]//g')\n\n"; # END OF THE RSS PARSER if [ -n "$2" ]; then echo "$1" > $FEED_BOOKMARKS/$2 echo -e "\\n\\t\\e[01;37m==> \\e[01;31mBookmark saved as \\e[01;36m\\e[04m$2\\e[00m\\e[01;37m <==\\e[00m\\n" fi } deef() { if test -n "$1"; then if [ ! -r "$FEED_BOOKMARKS/$1" ]; then echo -e "\\n \\e[01;31mBookmark \\e[01;36m\\e[04m$1\\e[00m\\e[01;31m not found.\\e[00m\\n\\n \\e[04mType:\\e[00m\\n\\n \\e[01;37m\$ deef\\e[00m (without arguments)\\n\\n to get the complete list of all currently saved bookmarks.\\n"; return 1; fi local url="$(cat $FEED_BOOKMARKS/$1)"; if [ ! -n "$url" ]; then echo "The bookmark is empty"; return 1; fi echo -e "\\n\\t\\e[01;37m==> \\e[01;31m$url\\e[01;37m <==\\e[00m" feed "$url"; else echo -e "\\n \\e[04mUsage\\e[00m\\n\\n \\e[01;37m\$ deef \\e[01;31m<bookmark>\\e[00m\\n\\n \\e[04mCurrently saved bookmarks\\e[00m\\n"; for i in $(find $FEED_BOOKMARKS -maxdepth 1 -type f); do echo -e " \\e[01;36m\\e[04m$(basename $i)\\e[00m"; done; echo -e "\\n \\e[04mSee also\\e[00m\\n\\n \\e[01;37m\$ feed\\e[00m\\n"; fi; }
Any idea about this error?
deef archnews
==> http://www.archlinux.org/feeds/news/ <==
sed: -e expression #1, char 772: unterminated `s' command
# Set N to be the number of latest news to fetch
NEWS=$(echo -e $(curl --silent https://www.archlinux.org/feeds/news/ | awk ' NR == 1 {N = 3 ; while (N) {print;getline; if($0 ~ /<\/item>/) N=N-1} ; sub(/<\/item>.*/,"</item>") ;print}'))
# Remove some tags
NEWS=$(echo -e $NEWS | \
awk '{
# uncomment to remove first line which is usually not a news item
sub(/<lastBuildDate[^>]*>([^>]*>)/,"");sub(/<language[^>]*>([^>]*>)/,"");sub(/<title[^>]*>([^>]*>)/,"");sub(/<link[^>]*>([^>]*>)/,"");
while (sub(/<guid[^>]*>([^>]*>)/,""));
while (sub(/<dc:creator[^>]*>([^>]*>)/,""));
while (sub(/<description[^>]*>([^>]*>)/,"")); print }' | \
sed -e ':a;N;$!ba;s/\n/ /g')
echo -e "$(echo -e $NEWS | \
sed -e 's/&/\&/g
s/<\|</</g
s/>\|>/>/g
s/<\/a>/£/g
s/href\=\"/§/g
s/<title>/\\n\\n :: \\e[01;31m/g; s/<\/title>/\\e[00m ::/g
s/<link>/\\n [ \\e[01;36m/g; s/<\/link>/\\e[00m ]\\n/g
s/<p\( [^>]*\)\?>\|<br\s*\/\?>/\n/g
s/<b\( [^>]*\)\?>\|<strong\( [^>]*\)\?>/\\e[01;30m/g; s/<\/b>\|<\/strong>/\\e[00;37m/g
s/<i\( [^>]*\)\?>\|<em\( [^>]*\)\?>/\\e[41;37m/g; s/<\/i>\|<\/em>/\\e[00;37m/g
s/<u\( [^>]*\)\?>/\\e[4;37m/g; s/<\/u>/\\e[00;37m/g
s/<code\( [^>]*\)\?>/\\e[00m/g; s/<\/code>/\\e[00;37m/g
s/<a[^§|t]*§\([^\"]*\)\"[^>]*>\([^£]*\)[^£]*£/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g
s/<li\( [^>]*\)\?>/\n \\e[01;34m*\\e[00;37m /g
s/<!\[CDATA\[\|\]\]>//g
s/\|>\s*<//g
s/ *<[^>]\+> */ /g
s/[<>£§]//g')"
do you guys have the same version of the script, but without the parsing of the content ? Without the content mark in fact.
Sincerely
]]>For now I have not enough time, but I think you can also fix the Wiki (I don't use this script, so I am unable to search for bugs)...
Fixed.
Of course! Post it!
It needs some polish, if done i will replace the wiki entry if you like it. However, it will take some time, because i am quite busy right now.
]]>@grufo:
There is a small bug in the parser (as you also can see in the wiki-entry simulation): the link target is not correct.
Thank you very mutch!
For now I have not enough time, but I think you can also fix the Wiki (I don't use this script, so I am unable to search for bugs)...
Btw: I hacked together an extended function for the login message like suggested in the wiki. It will only print the top message and tries to avoid needless downloads and views. Any interest?
Of course! Post it!
]]>There is a small bug in the parser (as you also can see in the wiki-entry simulation): the link target is not correct.
Change
s/<a[^§] ...
to
s/<a[^§|t] ...
to make it work as expected, otherwise sed will match for "<atomic ...", which is the feed link itself.
Btw: I hacked together an extended function for the login message like suggested in the wiki. It will only print the top message and tries to avoid needless downloads and views. Any interest?
]]>Thank you,
]]>