Re: Bash function not working…

Johnny Rosenberg gurus.knugum at gmail.com
Tue Jan 8 17:21:08 UTC 2013


2013/1/8 Paul Smith <paul at mad-scientist.net>:
> On Tue, 2013-01-08 at 18:07 +0100, Johnny Rosenberg wrote:
>> Can I just run the .bash-functions file
>> (after given it run permissions), for example?
>
> No.  Running it would have it start a subshell, the subshell would
> create all those functions, then the sub-shell would then exit... and
> all the new functions you just defined in that subshell would be lost.
>
> You have to source the file, not run it (and it doesn't need to be
> executable--in fact you should not make it executable so people don't
> execute it by accident), so that it will take effect in the current
> shell instead.
>
> Use either:
>
>         . .bash-functions
>
> or:
>
>         source .bash-functions
>
> (the latter is a Bash extension which doesn't work in POSIX standard
> shells).

Thanks! I'll try to remember that until next time.


Johnny Rosenberg




More information about the ubuntu-users mailing list