This is 'kinda' confusing me - I'm trying to run one of two options depending on the content of a variable previously set up via export.
I'll display the script and then display the result - which is confusing me since it 'appears' the variable is passing the two different if tests - despite it only being valid for one of them.
The script: called Mk
exportBV="V"echo$BVif["$BV"="B"]thenechoFoundBDB
fiif["$BV"="V"]thenechoFoundVBI
fi
The results:
$ mk
V
Found BDB
Found VBI
What am I doing wrong ??.
TIA - Thanks in anticipation.
Last edit: Simon Sobisch 2021-09-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not sure, but I suppose since there is no spaces between the equals signs in the if statement, then it perceives it as a true type of Boolean?
Try it with spaces on before and after the = sign in the if statement.
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is 'kinda' confusing me - I'm trying to run one of two options depending on the content of a variable previously set up via export.
I'll display the script and then display the result - which is confusing me since it 'appears' the variable is passing the two different if tests - despite it only being valid for one of them.
The script: called Mk
The results:
What am I doing wrong ??.
TIA - Thanks in anticipation.
Last edit: Simon Sobisch 2021-09-02
Not sure, but I suppose since there is no spaces between the equals signs in the if statement, then it perceives it as a true type of Boolean?
Try it with spaces on before and after the = sign in the if statement.
Thank you Mickey - got it in 1 - much appreciated.
I'd already switched the test to a case statement but the if looks better I think.
Have a beer on me.