🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #924

Re: alias

#924
From: Chet Ramey
Date: Tue, 01 Sep 1992 06:36
35 lines
1335 bytes
> How do you get, in an alias, the rest of the command line expanded?
> If I write
> 	alias xx='echo abc 777 def'
> and
> 	xx this is fun
> should print
> 	abc this is fun def
>
> What do I need to write instead of the '777'? Could not find
> anything in the documentation. It's a bug in that it's not documented .......

You cannot do what you want with aliases.  What you want to use
are shell functions:

xx()
{
	echo abc $@ def
}

As for it being documented, this text appears in the bash-1.12
manual page, section ALIASES:

	There is no mechanism for using arguments in the
	replacement text, a la csh.  If arguments are needed,
	a shell function should be used.

Chet



--
``The use of history as therapy means the corruption of history as history.''
	-- Arthur Schlesinger

Chet Ramey, Case Western Reserve University	Internet: chet@po.CWRU.Edu
Technical Details
Message-ID: <9209011436.AA16705.SM@odin.INS.CWRU.Edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!odin.ins.cwru.edu!chet
References: chet@odin.ins.cwru.edu (Chet Ramey)

Show Full Headers
Complete Article Headers
Newsgroups: gnu.bash.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!odin.ins.cwru.edu!chet
From: chet@odin.ins.cwru.edu (Chet Ramey)
Subject: Re: alias
Message-ID: <9209011436.AA16705.SM@odin.INS.CWRU.Edu>
Sender: gnulists@ai.mit.edu
Reply-To: chet@po.cwru.edu
Organization: GNUs Not Usenet
References: chet@odin.ins.cwru.edu (Chet Ramey)
Distribution: gnu
Date: Tue, 1 Sep 1992 06:36:06 GMT
Approved: bug-bash@prep.ai.mit.edu
Lines: 36