From 1e9538a914de8cc2e3a1078fe99a9241a9dcca58 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sun, 11 Dec 2016 22:13:17 +0000 Subject: [PATCH] url2nc --- etc/profile.d/functions | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etc/profile.d/functions b/etc/profile.d/functions index ca892113..2587c20c 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -594,6 +594,9 @@ is_prompt() { url2nc() { local in="cat"; [ -n "$*" ] && in="echo $*"; + eval $in | perl -ne ' BEGIN{%p=("ssh"=>22,"https"=>443,"http"=>80);}; /([\w\._-]+):(\d+)/ and print "$1 $2\n" and next; m,^\w+://, or $_="ssh://$_"; m,^(\w+)://(?:[^@]+@)?([\w\._-]+), and print "$2 ".($p{$1}||22)."\n" and next' + return + # NB 11.12.16: TODEL local IFS=$'\n' eval $in | perl -MURI::Split -ne 'BEGIN{%port=("ssh"=>22,"https"=>443,"http"=>80);}; chomp($_); @@ -604,6 +607,7 @@ url2nc() { s,:([a-zAZ]),/$1,; m,^\w+://, or $_="ssh://$_"; @_ = URI::Split::uri_split($_) or next; + if (0) { use Data::Dumper; warn Dumper(\@_); } $_[1] =~ s/:(.*$)// and $_[2] = $1.$_[2]; } -- 2.47.3