[Surfraw-devel] OS X sed and basic regular expressions
Donavan-Ross Costaras
d.costaras at gmail.com
Fri Nov 21 22:23:03 UTC 2014
Hi all,
Can I suggest...
--- surfraw-original 2014-11-21 23:40:16.000000000 +0200
+++ surfraw-fix 2014-11-21 23:40:59.000000000 +0200
@@ -324,7 +324,7 @@
list_elvi() {
local dir="$1"
- sed -n 's/^.*elvis:[ ]\+\(.*\)$/\1/p' $(find "$dir" ! -type d ! -type l ! -name '*~' | sort)
+ sed -n 's/^.*elvis:[ ]\{1,\}\(.*\)$/\1/p' $(find "$dir" ! -type d ! -type l ! -name '*~' | sort)
for script in $(find "$dir" ! -type d -type l | sort) ; do
printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}"))
done
...as OS X basic regular expressions do not support the `+'
metacharacter. I believe this is POSIX.2 and the `+' metacharacter is
non standard, though I may be wrong.
On the dev list archive there is an OS X user who seems to have it
working but he may have forgotten his GNU sed symlink
http://lists.alioth.debian.org/pipermail/surfraw-devel/2011-October/000968.html
Here is an extract of the OS X RE_FORMAT man page with the relevent section.
Obsolete (``basic'') regular expressions differ in several respects. `|'
is an ordinary character and there is no equivalent for its functional-
ity. `+' and `?' are ordinary characters, and their functionality can be
expressed using bounds (`{1,}' or `{0,1}' respectively).
I'd be happy to push the change myself though I've never done so for a
public project and would need guidance. A lot of tests seem to fail with
503 or 403 but I suspect this change would not effect those on my OS X
system but would need to be tested in other OSes.
Thanks for your time.
--
Regards,
Donavan-Ross Costaras
More information about the Surfraw-devel
mailing list