🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by jkh Tue, 18 Jul 1989 19:40
Alias bug in BASH 1.01
#349
Author: jkh
Date: Tue, 18 Jul 1989 19:40
29 lines
1197 bytes
The alias code is broken. Try the following:

bash% alias retch='echo \!*'
bash% retch foo bar blat
!* foo bar blat
bash%

The !* should expand into the current arg list, ala csh.
None of the other !<arg> constructs work in aliases either.

                                Jordan

P.S.:

function setenv () {
	eval $1=$2
	export $2
}

Works like a charm! Good job! I was all set to gripe about
not having setenv and being used to it and all, then I tried
that.. Ahem.. Never mind.

--------
                                Jordan Hubbard
                                PCS Computer Systeme GmbH
                                West Germany
        UUCP:                   {uunet,decwrl}!pyramid!pcsbst!jkh
        ARPA:                   jkh@violet.berkeley.edu
Re: Alias bug in BASH 1.01
#352
Author: Chet Ramey
Date: Wed, 19 Jul 1989 17:18
45 lines
1719 bytes
In article <926@pcsbst.UUCP> jkh@meepmeep.pcs.com ( Jordan K. Hubbard ) writes:
>The alias code is broken. Try the following:
>
>bash% alias retch='echo \!*'
>bash% retch foo bar blat
>!* foo bar blat
>bash%
>
>The !* should expand into the current arg list, ala csh.
>None of the other !<arg> constructs work in aliases either.

It's not a bug, it's a design decision.

The alias mechanism in bash is more akin to the way ksh does it
(rather than csh) in that it only performs simple textual substitution.
If you want the ability to use arguments, use shell functions instead.

>function setenv () {
>	eval $1=$2
>	export $2
>}
>

This should be 
	eval $1="$2"
	export $1

or even
	export $1="$2"

You need to quote the second argument because it will be expanded (this
example is from Brian Fox, from a discussion we were having about this):

	foo="foo and bar"
	setenv baz "$foo"
	  setenv->$2 = foo and bar
	  eval $1=$2 -> baz=foo and bar
	NOT             baz="foo and bar"

Chet Ramey

Chet Ramey			"We are preparing to think about contemplating 
Network Services Group, CWRU	 preliminary work on plans to develop a
chet@cwjcc.INS.CWRU.Edu		 schedule for producing the 10th Edition of 
				 the Unix Programmers Manual." -- Andrew Hume
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads