I am writing (my first) shell script, and, for flexibility would like to use variables. Here is a part of script I wrote following different examples searched:
#!/bin/sh
#
jar_path="/sbclocal/apps/blablabla"
echo $jar_path # <- OK
echo ${jar_path} # <- OK
echo $jar_path/jar # <- /jarlocal/apps/blablabla
echo "$jar_path/jar" # <- /jarlocal/apps/blablabla
echo ${jar_path}/jar # <- /jarlocal/apps/blablabla
echo "${jar_path}/jar" # <- /jarlocal/apps/blablabla
In the last line, I expect to get "/sbclocal/apps/blablabla/jar", but what I get is "/jarlocal/apps/blablabla"! So instead of concatenation, starting of the variable string is replaced with the constant part, which I expect in the end!
There is also more complex concatenation inside of the jar parameter, which gets broken in a way I can't figure out for sure, but I suppose the issue is the same.
What is wrong here please?
UPD: Edited to show different approaches I tried, all having the same result.
UPD: I have also tried with 2 variables, strange thing is that the first one is not shown, like it's empty, when I write something like
echo $var1$var2
echo ${var1}${var2}
echo ${var1}+${var2}
This is crazy, I think I will give up and use old plain copy-paste, as this will be much quicker.