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

Alternate for Perl? #33

Open
tspicer opened this issue Nov 8, 2016 · 6 comments
Open

Alternate for Perl? #33

tspicer opened this issue Nov 8, 2016 · 6 comments

Comments

@tspicer
Copy link

tspicer commented Nov 8, 2016

There is some processing/cleanup done using Perl. However, there are cases where Perl might not be available. Is there a SED or AWK alternative for the use of Perl?

Example:
perl -p -e "s/(?<!href=\"|href=')((?:https?|ftp|mailto)\:\/\/[^ \n]*)/\<a href=\"\1\"\>\1\<\/a>/g")

@jimsmith
Copy link
Contributor

jimsmith commented Mar 7, 2017

Is there any movement on this one ? , it's normally taken for granted Perl will be on the system, but that is not always the case in controlled environments.

@tspicer
Copy link
Author

tspicer commented Mar 7, 2017

Do you have a preference on approach?

@jimsmith
Copy link
Contributor

jimsmith commented Mar 8, 2017

I prefer sed.
http://stackoverflow.com/a/2489777

I threw this together briefly, obviously this is just showing for http url:

TEST=http://www.test.com/
echo $TEST
echo -n "${TEST}" | sed  -e "s|http[:]//[^ ]*|<a href=\"\0\">\0</a>|g"

Output:
<a href="http://www.test.com/">http://www.test.com/</a>

As for line https://github.com/hipchat/hipchat-cli/blob/master/hipchat_room_message#L110
again sed should do the trick!

http://sfyang-en.blogspot.co.uk/2012/04/url-encodingdecoding-with-shell-script.html
and some discussions around urlencode here - https://gist.github.com/cdown/1163649

@jimsmith
Copy link
Contributor

It has been over a month any movement on this one ?

@rberrelleza
Copy link
Contributor

If we don't use perl, is it ok to take for granted that AWK or SED might be in the system? I believe it's equally possible to have either of those in the system, but happy to review and accept a PR with the reasoning behind though.

@jimsmith
Copy link
Contributor

sounds reasonable also you could do a pre-req and check that the command(s) are there before the tool can be used.

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

3 participants