You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: notes/cli/shells.scrbl
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,19 @@
1
1
#lang notes
2
2
3
3
@block{@block-name{Shells: Bash & Fish-shell}
4
+
Bash has a feature called “subshells”, where it will start another shell process for certain things. That shell will then be independent and e.g. any changes it makes to variables won’t be visible in the main shell.
5
+
#
6
+
Fish does not currently have subshells. You will have to find a different solution.
7
+
The isolation can usually be achieved by scoping variables (with set -l), but if you really do need to run your code in a new shell environment you can use fish -c 'your code here' to do so explicitly.
8
+
() subshells are often confused with {} grouping, which does not use a subshell. When you just need to group, you can use begin; end in fish
9
+
#
10
+
Subshells are also frequently confused with command substitutions, which bash writes as `command` or $(command) and fish writes as $(command) or (command). Bash also uses subshells to implement them.
11
+
#
12
+
TODO list of fish functions using () grouping
13
+
❯ cd $dtf/.config/fish/functions ─╯
14
+
❯ rg -l -g '*.{fish}' '.\(' | rg -v tide\|getopps
15
+
16
+
4
17
# check if a file contains only binary zeros
5
18
# https://stackoverflow.com/a/20226139/5151982
6
19
# bash (`cat` shouldn't be used in scripts, only on command line)
0 commit comments