Skip to content

Script vs functions?? #10118

Closed Answered by faho
BarbzYHOOL asked this question in Q&A
Nov 24, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

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…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BarbzYHOOL
Comment options

Answer selected by zanchey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants