On 03/16/2012 02:56 PM, gregrwm wrote: > a function invoking an alias works, unless they are defined within the same > conditional, eg:
Thanks for the report, but this is not a bug. Remember, aliases affect parsing, so they can only be expanded during the parsing phase. But bash has to parse until the end of a compound command before it can do any action within the command. In that sense, 'alias' is exactly like 'set -v' just recently discussed here: https://lists.gnu.org/archive/html/help-bash/2012-03/msg00025.html > > $ if true;then >> alias aseparate='echo aseparate' >> fi > $ if true;then >> fseparate ()(aseparate) >> fi Bash parsed two commands, so the parse of the second command was done with the alias expansion of the first command in effect. > $ if true;then >> alias atogether='echo atogether' >> ftogether ()(atogether) >> fi Here, bash parses the entire compound command, then starts executing it. At the time of the parse, ftogether() was declared without any extra meaning for atogether. > $ aseparate > aseparate > $ fseparate > aseparate > $ atogether > atogether > $ ftogether > bash: atogether: command not found This behavior is expected, and not a bug. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature