In a bash script that captures a href link, how does bash know that TEXT is a link and not a typical string? Why at the end when $TEXT="www.google.com", TEXT is still a link? Can you do that with a file? For example having a 'Click me' that runs a scrip.
shopt -s nocasematch
TEXT='<a href="http://www.google.com/search/something/lulz/here2 i=!mfo1iu489fn1o2jlk21m4098mdoi">"test link"</a><br>'
TEXT=${TEXT##*href=\"}
TEXT=${TEXT%%\"*}
TEXT=${TEXT##*//}
TEXT=${TEXT%%/*}
echo $TEXT
I'd say that bash itself doesn't recognize links. But some terminal emulators do
echo http://www.google.com
or 'echo www.google.com' terminal with allow you to click on link, but echo google.com
will not be recognized as one - it most likely depends on http://
prefix (clearly indicating that it's a link) or www
prefix (often occurring at www adress),From how bash scripts are used I'd say that there is no implementation independent way to add clickable URLs into bash. But you can used described way to obtain similar behavior in terminal emulators. Alternatively, obtain from user some yes-no variable, and use it in conditional program call:
read openpage
if $openpage -eq "yes"
# open browser with your URL
fi
where how to open webpage is described e.g. here.
As for the files, I'd stay with just if $runfile -eq "yes" then command; fi
. Basically bash wasn't made with any GUI interaction on mind - it's a terminal after all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With