Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Best practices for managing aliases in ohmyzsh?



On Tue, Aug 31, 2021, at 10:33 PM, Ray Andrews wrote:
> On 2021-08-31 5:28 p.m., Bart Schaefer wrote:
> > Sourcing a file is not the same as executing a script.
> >
> Yikes, I'm missing something fundamental.  In my head, executing a 
> script is identical to sourcing it.

If you want to go a little deeper than Bart's summary, here's some
light bedtime reading.

https://homepages.cwi.nl/~aeb/std/hashexclam-1.html
https://www.in-ulm.de/~mascheck/various/shebang/

> If a function is declared (yes I know, wrong word but you get my
> meaning) then the function enters memory, otherwise it's
> interpret-and-forget until next time, no?

I don't really know what you mean here.

> If 'chmod +x' then you don't hafta 'say' 'source me', it's
> automatic, and it will be found if on the path, etc, but I'm
> laboring under the idea that nothing else is different.

It's trivial to confirm that this is not the case.

% cat ./foo
#!/bin/zsh

foo=2
typeset -p foo
% chmod +x ./foo
% foo=1
% typeset -p foo
typeset foo=1
% ./foo
typeset foo=2
% typeset -p foo
typeset foo=1
% . ./foo
typeset foo=2
% typeset -p foo
typeset foo=2


-- 
vq




Messages sorted by: Reverse Date, Date, Thread, Author