[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Alias in command substitution
From: |
Kerin Millar |
Subject: |
Re: Alias in command substitution |
Date: |
Wed, 21 Jun 2023 09:33:54 +0100 |
On Wed, 21 Jun 2023 13:40:56 +0530
LitHack <lithack0@gmail.com> wrote:
> Normally declaring a alias inside the command substitution would not
> reflect in main shell like........
> lithack@aura:~$ `alias l=ls`
> lithack@aura:~$ l
> l: command not found
> But using this command .....
> lithack@aura:~$ `alias l=ls;alias`
> lithack@aura:~$ l
> api Desktop Downloads Music __py__ v v.zip
> Arjun dir idafree82_linux.run Pictures snap vi
> BurpSuiteCommunity Documents 'IDA Freeware 8.2.desktop' Public
> Templates Videos
> It runs in main shell. Is this a bug?
No. This is what happens.
1) an alias is declared in the subshell incurred by the `command substitution`
2) the alias builtin is executed, which prints out a declaration of the
just-declared alias
3) the command substitution causes that which was just printed to be evaluated
in the original shell
4) an alias is thus declared in the original shell
As Lawrence advised in a different thread, such questions would be more
appropriately posed at the help-bash list.
--
Kerin Millar