delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/10/06/15:41:53

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
In-Reply-To: <Pine.GSO.4.61.0410061338090.24166@slinky.cs.nyu.edu>
To: cygwin AT cygwin DOT com
MIME-Version: 1.0
Subject: RE: Mailing list redirection etiquette?
Message-ID: <OFB78B104E.67DADE8F-ON86256F25.00681CCC-86256F25.0068967F@us.ibm.com>
From: Fred Kulack <kulack AT us DOT ibm DOT com>
Date: Wed, 6 Oct 2004 14:02:21 -0500
X-IsSubscribed: yes

On 10/06/2004 at 01:09:39 PM, cygwin-owner wrote:
but this won't quote the arguments properly -- if you want that, you need 
something like

google () {
    url="http://www.google.com/search?q=`echo -n $*|perl -mCGI -pe 
'$_=CGI::escape($_)'`";
    echo "Starting: $url"; cygstart -o "$url" >/dev/null
}
--- end of excerpt ---

Sigh... You can't just put that comment out there like that can you... 8-)
That doesn't get them quite right either. 8-)
> google "oh what the hell"
Starting: http://www.google.com/search?q=oh%20what%20the%20hell

Using $@ and adding double quotes to any strings with spaces before 
running them through CGI::escape does one more step nicely.
Note that I prefer somewhat verbose perl code. 

google () {
    qry=$(perl -mCGI -e 'undef $qry; for ($i=0; $i<=$#ARGV; $i++) { if 
($ARGV[$i] =~ m/ /) { $ARGV[$i]="\"$ARGV[$i]\""; } if (defined $qry) 
{$qry.=" ";} $qry.=CGI::escape($ARGV[$i]); }; print "$qry\n";' $@)
    url="http://www.google.com/search?q=$qry";
    echo "Starting: $url"; cygstart -o "$url" >/dev/null
}

> google "oh what the hell" is this
Starting: 
http://www.google.com/search?q=%22oh%20what%20the%20hell%22%20is%20this

NQLGGOB...  8-)




"The stuff we call "software" is not like anything that human society 
  is used to thinking about. Software is something like a machine, and 
  something like mathematics, and something like language, and 
  something like thought, and art, and information... 
  but software is not in fact any of those other things."
Bruce Sterling - The Hacker Crackdown

Fred A. Kulack - IBM eServer iSeries - Enterprise Application Solutions
ERP, Java DB2 access, Jdbc, JTA, etc...
IBM in Rochester, MN  (Phone: 507.253.5982   T/L 553-5982)
mailto:kulack/us.ibm.com   Personal: mailto:kulack/magnaspeed.net
AIM Home:FKulack  AIM Work:FKulackWrk 
MSN Work: fakulack/hotmail.com (replace email / with @)

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019