You are not logged in.
Pages: 1
I am trying out the fish shell, and I like it. However, in my university, I need to work with simulation programs written in bash, and unfortunately, some of them don't have a proper shebang line. I wanted to test how fish reacts to such scripts, so I made this sample script that works in bash, but not in fish:
# Using Bash-specific array syntax
my_array=(one two three)
# Looping through the array
for item in "${my_array[@]}"; do
echo "Item: $item"
done
# Using a Bash-style function
my_function() {
echo "This is a Bash-specific function."
}
my_function
There is no shebang line, so I expected it would fail if I ran it directly (by `./demo`. The file name is demo). However, to my surprise, the script executed fine. So, fish used bash to run the script. Running `fish demo`, or adding a fish shebang, caused the script to fail, obviously. I then changed the script to work for fish and not bash:
# Using Fish-specific array syntax
set my_array one two three
# Looping through the array
for item in $my_array
echo "Item: $item"
end
# Using a Fish-style function
function my_function
echo "This is a Fish-specific function."
end
my_function
Running it directly actually failed with bash errors. So fish runs scripts with bash instead of itself? That seemed very weird to me until I found this in the docs (http://fishshell.com/docs/current/inde … ebang-line). So, in the absence of a shebang line, fish uses the system shell to execute scripts. The next natural question is how I determine the system shell? My login shell is certainly set to fish, as `echo $SHELL` prints `/usr/bin/fish`. But how can I find what the system shell is on Arch Linux? The docs say that it's normally `/bin/sh`, which explains why bash scripts work and fish scripts don't work without a shebang line, but how can I verify it? I tried to search online, but all I found were 20 different ways to get the interactive or login shell, not the system shell.
Offline
Fish will most likely use http://man.archlinux.org/man/system.3
Offline
Their docs made me believe there is a concept of "system shell" in Linux. Is there something like that, or do they simply use this function to call /bin/sh?
Offline
The closest thing to a "system shell" is /bin/sh, but what usually happens is to invoke that system() function and that is then implemented to run /bin/sh
What fish does exactly idk specifically, you'd have to ask the developers - or search the code.
Offline
Pages: 1