06-09-2018, 07:20 PM
OK, to update the results. All went fine! I installed the fish shell via the Synaptic package manger. This was not on a VM, it was on my real LL 4.0 machine (I'd backed up user data onto a USB drive first). Please note, I did NOT set up fish as my login shell, just to be safe! I'm only planning to use fish when I do scripting.
OK, here is a case in point where I'm comparing bash and fish on the "if" statement, where bash falls down under a certain condition (just a comment inside the 'if').
The "date" command in the script is just so we know when we've gone past the if statement and gotten to the end of the script.
BASH:
Here is a bash script I made called test-if-comment.bash:
Here is the output of test-if-comment.bash:
./test-if-comment.bash: line 6: syntax error near unexpected token `fi'
./test-if-comment.bash: line 6: ` fi'
The output is an error because it doesn't like to have an if statement containing only a comment. This is exactly why I don't like bash. This sort of thing makes me want to cry!
So in order to have the thing run, I need to put something else other than just a comment inside the if statement. OK, let's try putting an echo statement in there.
We will call this file test-if-comment-echo.bash
Here is the output of test-if-comment-echo.bash - it's what we would expect:
Placeholder text
Sat JunĀ 9 15:08:39 EDT 2018
FISH
OK, let's try the equivalent of the first shell script but in fish. We'll call it test-if-comment.fish
Here is the output of test-if-comment.fish - evidently the fish shell is fine with just a comment inside the if statement:
Sat JunĀ 9 15:11:28 EDT 2018
I also tested the fish script with an echo inside the if statement as well as the comment, just to make sure it was working properly, and it was.
I think I will be sticking with fish for my scripting needs. It seems to work more intuitively for me.
OK, here is a case in point where I'm comparing bash and fish on the "if" statement, where bash falls down under a certain condition (just a comment inside the 'if').
The "date" command in the script is just so we know when we've gone past the if statement and gotten to the end of the script.
BASH:
Here is a bash script I made called test-if-comment.bash:
Code:
#!/bin/bash
mynumber=3
if [ $mynumber -eq 3 ]
then
# we only want a comment here
fi
date
Here is the output of test-if-comment.bash:
./test-if-comment.bash: line 6: syntax error near unexpected token `fi'
./test-if-comment.bash: line 6: ` fi'
The output is an error because it doesn't like to have an if statement containing only a comment. This is exactly why I don't like bash. This sort of thing makes me want to cry!
So in order to have the thing run, I need to put something else other than just a comment inside the if statement. OK, let's try putting an echo statement in there.
We will call this file test-if-comment-echo.bash
Code:
#!/bin/bash
mynumber=3
if [ $mynumber -eq 3 ]
then
# we only want a comment here but we have to put something else in
echo "Placeholder text"
fi
date
Here is the output of test-if-comment-echo.bash - it's what we would expect:
Placeholder text
Sat JunĀ 9 15:08:39 EDT 2018
FISH
OK, let's try the equivalent of the first shell script but in fish. We'll call it test-if-comment.fish
Code:
#! /usr/bin/fish
set mynumber 3
if test $mynumber -eq 3
# we only want a comment here
end
date
Here is the output of test-if-comment.fish - evidently the fish shell is fine with just a comment inside the if statement:
Sat JunĀ 9 15:11:28 EDT 2018
I also tested the fish script with an echo inside the if statement as well as the comment, just to make sure it was working properly, and it was.
I think I will be sticking with fish for my scripting needs. It seems to work more intuitively for me.
Using Linux Lite for everything now. I put it on my desktop and my laptop. Woohoo!