Script vs functions?? #10118
-
Hello, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
A function will run directly inside of your shell. That means it'll be able to touch your shell's environment directly - it can set variables that stay, it can A script will run in its own shell. That means it's somewhat isolated - it won't be affected by many things in your shell (except for exported variables), and it can't do many things to your shell. Fish is a bit special in this regard because it reads all config by default (i.e. unless you run it specifically with If you want to give your thing to people who use other shells, it'll have to be a script. |
Beta Was this translation helpful? Give feedback.
A function will run directly inside of your shell.
That means it'll be able to touch your shell's environment directly - it can set variables that stay, it can
cd
, it can run other functions, ...A script will run in its own shell. That means it's somewhat isolated - it won't be affected by many things in your shell (except for exported variables), and it can't do many things to your shell. Fish is a bit special in this regard because it reads all config by default (i.e. unless you run it specifically with
--no-config
), so even a script will have access to your functions etc, so the difference is less than it would be in other shells.If you want to give your thing to people who use other…