accwai@WATMATH.WATERLOO.EDU (Andy Wai) (08/23/89)
| Date: Tue, 22 Aug 89 20:35:20 EDT | From: "Ian! D. Allen [CGL]" <idallen@watcgl> | To: accwai@watmath | Subject: bash aliases not transitive?! | | bash$ alias a=b | bash$ alias b=date | bash$ a | b: commmand not found The version in question is 1.02. Andy Wai Math. Faculty Computing Facility U. of Waterloo
bfox@AUREL.CALTECH.EDU (Brian Fox) (08/23/89)
Date: Wed, 23 Aug 89 11:45:28 EDT From: Andy Wai <accwai@watmath.waterloo.edu> > Date: Tue, 22 Aug 89 20:35:20 EDT > From: "Ian! D. Allen [CGL]" <idallen@watcgl> > To: accwai@watmath > Subject: bash aliases not transitive?! > > bash$ alias a=b > bash$ alias b=date > bash$ a > b: commmand not found The version in question is 1.02. Andy Wai Math. Faculty Computing Facility U. of Waterloo Aliases are only expanded when they are in the position of a command word, or if they follow an alias whose expansion ends in a space. Brian
accwai@WATMATH.WATERLOO.EDU (Andy Wai) (08/24/89)
| Date: Wed, 23 Aug 89 09:50:51 PDT | From: bfox@aurel.caltech.edu (Brian Fox) | Reply-To: bfox@aurel.caltech.edu | | Date: Wed, 23 Aug 89 11:45:28 EDT | From: Andy Wai <accwai@watmath.waterloo.edu> | | > Date: Tue, 22 Aug 89 20:35:20 EDT | > From: "Ian! D. Allen [CGL]" <idallen@watcgl> | > To: accwai@watmath | > Subject: bash aliases not transitive?! | > | > bash$ alias a=b | > bash$ alias b=date | > bash$ a | > b: commmand not found | > [...] | | Aliases are only expanded when they are in the position of a command | word, or if they follow an alias whose expansion ends in a space. | | Brian I think alias expansion should be transitive. In the above example, 'a' should be expanded into 'date'. In fact, that's what ksh does. Is there any reason why this behavior is not desirable? Andy Wai
maart@cs.vu.nl (Maarten Litmaath) (08/24/89)
bfox@AUREL.CALTECH.EDU (Brian Fox) writes:
\ From: Andy Wai <accwai@watmath.waterloo.edu>
\ > From: "Ian! D. Allen [CGL]" <idallen@watcgl>
\...
\ > bash$ alias a=b
\ > bash$ alias b=date
\ > bash$ a
\ > b: commmand not found
\...
\Aliases are only expanded when they are in the position of a command
\word, or if they follow an alias whose expansion ends in a space.
Could you explain why, Brian? Isn't non-transitivity of aliases very annoying?
--
"rot H - dD/dt = J, div D = rho, div B = 0, |Maarten Litmaath @ VU Amsterdam:
rot E + dB/dt = 0" and there was light. |maart@cs.vu.nl, mcvax!botter!maart
bfox@AUREL.CALTECH.EDU (Brian Fox) (08/24/89)
Date: Wed, 23 Aug 89 15:38:47 EDT From: Andy Wai <accwai@watmath.waterloo.edu> > Date: Wed, 23 Aug 89 09:50:51 PDT > From: bfox@aurel.caltech.edu (Brian Fox) > Reply-To: bfox@aurel.caltech.edu > > Date: Wed, 23 Aug 89 11:45:28 EDT > From: Andy Wai <accwai@watmath.waterloo.edu> > > > Date: Tue, 22 Aug 89 20:35:20 EDT > > From: "Ian! D. Allen [CGL]" <idallen@watcgl> > > To: accwai@watmath > > Subject: bash aliases not transitive?! > > > > bash$ alias a=b > > bash$ alias b=date > > bash$ a > > b: commmand not found > > [...] > > Aliases are only expanded when they are in the position of a command > word, or if they follow an alias whose expansion ends in a space. > > Brian I think alias expansion should be transitive. In the above example, 'a' should be expanded into 'date'. In fact, that's what ksh does. Is there any reason why this behavior is not desirable? Andy Wai You keep using the word 'transitive' when in actuality you want aliases to be expanded purely based on textual matches, irregardless of location. Am I making a correct assumption? Brian
bfox@AUREL.CALTECH.EDU (Brian Fox) (08/24/89)
Date: 23 Aug 89 19:50:20 GMT
From: maart@star.cs.vu.nl (Maarten Litmaath)
Organization: V.U. Informatica, Amsterdam, the Netherlands
References: <8908231545.AA19132@watmath.waterloo.edu>, <8908231650.AA01210@aurel.caltech.edu>
Sender: bug-bash-request@prep.ai.mit.edu
bfox@AUREL.CALTECH.EDU (Brian Fox) writes:
\ From: Andy Wai <accwai@watmath.waterloo.edu>
\ > From: "Ian! D. Allen [CGL]" <idallen@watcgl>
\...
\ > bash$ alias a=b
\ > bash$ alias b=date
\ > bash$ a
\ > b: commmand not found
\...
\Aliases are only expanded when they are in the position of a command
\word, or if they follow an alias whose expansion ends in a space.
Could you explain why, Brian? Isn't non-transitivity of aliases very annoying?
Not if you don't expect it to take place. On the other hand, not
knowing which way aliases will be expanded is very annoying. I don't
see a good reason to change the implementation as it stands.
This is a very interesting discussion. It seems to me that people
really only want one thing: the left-hand side of an alias expansion
should be alias expanded.
Brian
siegel@DSPO.GOV (Josh Siegel) (08/24/89)
In article <8908232037.AA02389@aurel.caltech.edu> bfox@aurel.caltech.edu writes: > > I think alias expansion should be transitive. In the above example, > 'a' should be expanded into 'date'. In fact, that's what ksh does. Is > there any reason why this behavior is not desirable? > > Andy Wai > >You keep using the word 'transitive' when in actuality you want aliases >to be expanded purely based on textual matches, irregardless of >location. > >Am I making a correct assumption? > >Brian No, he wants aliases to be expanded till either a count is reached (alias loop) OR it no longer expands into anything new. alias_expand() can be modified to loop until no more expansions are possible. In this case, a modification to alias_expand would/could be put it so that when a alias is used once, it is suppressed for that expansion. This would prevent alias loops. For example, the following would not result in a alias loop. alias ls=ls -CF BUT: alias iheader='echo -n $si !* $ei' alias ih=iheader alias cd='cd \!*; header $hostname $PWD' alias pushd='pushd \!*; header $hostname $PWD' alias popd='popd \!*; header $hostname $PWD' alias suspend='suspend \!*; header $hostname $PWD' alias fg='fg \!*; header $hostname $PWD' alias pwd='pwd \!*; header $hostname $PWD' Would work. When do we get 1.03? --josh -- Josh Siegel (siegel@hc.dspo.gov) Friends don't let Friends eat Cherry Zingers
maart@cs.vu.nl (Maarten Litmaath) (08/25/89)
bfox@AUREL.CALTECH.EDU (Brian Fox) writes:
\...
\This is a very interesting discussion. It seems to me that people
\really only want one thing: the left-hand side of an alias expansion
\should be alias expanded.
Indeed! That's the way csh does it.
Example (csh):
alias a alias
a b 'cd $b'
a cd 'set tmp=$cwd; chdir \!*; echo $cwd; set b=$tmp'
The `cd' in the expansion from `b' will be expanded (upon invokation).
Otherwise I would have to say:
a b 'set tmp=$cwd; chdir $b; echo $cwd; set b=$tmp'
a cd 'set tmp=$cwd; chdir \!*; echo $cwd; set b=$tmp'
Not nice.
--
"curl H - dD/dt = J, div D = rho, div B = 0,|Maarten Litmaath @ VU Amsterdam:
curl E + dB/dt = 0" and there was light. |maart@cs.vu.nl, mcvax!botter!maart