delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/05/00:47:44

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Date: Wed, 5 Jun 2002 00:20:57 -0400
From: rich-paul AT rich-paul DOT net
To: cygwin AT cygwin DOT com
Subject: Re: run batch w/o .bat?
Message-ID: <20020605002057.A19445@monster.rich-paul.net>
References: <C69F6A9E1E1F5A488C58B168F0875F4005BDA000 AT riv-exch1 DOT echosta r.com> <5 DOT 1 DOT 0 DOT 14 DOT 2 DOT 20020604201756 DOT 02a49b80 AT pop3 DOT cris DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.3.16i
In-Reply-To: <5.1.0.14.2.20020604201756.02a49b80@pop3.cris.com>; from rrschulz@cris.com on Tue, Jun 04, 2002 at 08:21:11PM -0700
X-Operating-System: Linux monster 2.4.17-SMPs

Actually, it looks like he was trying to do an oops script, for the
command after, which would be more like:

doh() {
	eval `history 2 | sed '2d;s/\s+[0-9]+\s+\([^\s]+\)/\1.bat'`
}
or for the non-sedders among us:
	gimme the last 2 lines of history
	(now the sed)
	throw away the last line (which will be doh)
	throw away the leading white, the group of digits, and the next
		white
	and append the .bat to the next token.

I haven't tested this, so sorry if the sed is wrong, but I have done an
eval of the output of history, w/o the first number, which worked.

On Tue, Jun 04, 2002 at 08:21:11PM -0700, Randall R Schulz wrote:
> Kevin,
> 
> BASH's aliases do not have all the functionality of CSH/TCSH aliases. In 
> particular, they cannot access the history mechanism. If you want to do 
> more than simple left-substitution of the command name, you should use a 
> shell procedure instead.
> 
> This should be equivalent to what you're trying:
> 
> bat() {
>          batName="$1.bat"
>          shift
>          "$batName" "$@"
> }
> 
> 
> Randall Schulz
> Mountain View, CA USA
> 
> 
> 
> At 14:46 2002-06-04, Barnhart, Kevin wrote:
> >Actually, I would settle for something like the following:
> >
> >alias 'bat'='!:0-0.bat !:1*'
> >
> >I'd like to add this into .bashrc.  Problem is that when I type in 'bat' at
> >the command line I get the following error:
> >bash: !:0-0.bat: command not found
> >
> >I'm tried to escape the bang with a '\', but to no avail.  If I type:
> >!:0-0.bat !:1*
> >at the command line then there is no problem--it does what is supposed to,
> >which is to append '.bat' to the 0-word of the previous command.
> >
> >Help?
> >
> >Kevin
> 
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 

-- 
Got freedom?  Vote Libertarian:  http://www.lp.org

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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