> #!/bin/sh
> xterm -e "telnet `echo ${*##telnet://} | sed 's/:/ /g'`"
[...]
> - I *think* the {} bit is awk(1),

No, "/bin/sh" is not awk(1), but sh(1).   =;c)

[...]
> If awk(1) can remove telnet:// from $* (if present),
> then surely it should be able to turn a colon (if present)
> into a space, right?

Parameter substitution in /bin/sh can only remove characters
from the beginning or the end of a string, not substitute
something in the middle, see sh(1).

But rather than torturing your poor sh(1), let's rather start over.
First you understand your task, then you choose your tools.
You need
 [1] non-interactive editing capabilities
 [2] command interpreter capabilities

As sh(1) is lacking [1] and sed is lacking [2], you should really
pick some other language, e.g. awk(1) or perl(1).  Indeed, awk(1)
has a system()-call, but i'm not fluent in awk, so let's get the
job done using perl:

#!/usr/bin/perl
use warnings;
use strict;
my $url = shift;
exec 'xterm','-e', 'telnet',$1,$2 if $url =~ m#^telnet://([-.\w]*?):(\d+)$#;
exec 'xmessage', "$url: parse error";


On a side note, do not use
  exec "xmessage $url: parse error";
or surfing to
  telnet://localhost:1234&halt#
might yield surprising results.

Your sh-kludge cited above is even worse; please DO try surfing to
  telnet://localhost:1234&xmessage:bad:guys:got:in
but do NOT try surfing to
  telnet://localhost:1234&rm:-rf:~

Reply via email to