cola
1
Why isn't printing message?
1 #!/bin/sh
2
3 something(){
4 echo "Inside something"
5 echo $1 $2
6 }
7 val=$(something "Hello " "world")
But it prints.
1 #!/bin/sh
2
3 something(){
4 echo "Inside something"
5 echo $1 $2
6 }
7 val=$(something "Hello " "world")
8 echo $val
danmero
2
I don't see any error's
# cat script.sh
#!/bin/sh
something(){
echo "Inside something"
echo $1 $2
}
val=$(something "Hello " "world")
echo "$val"
# ./script.sh
Inside something
Hello world
cola
3
Yes there is no error.
But the script bellow doesn't display anything.Why?
1 #!/bin/sh
2
3 something(){
4 echo "Inside something"
5 echo $1 $2
6 }
7 val=$(something "Hello " "world")
pludi
4
Why should it? You never tell it to. The echos in your function get captured by $(...), and whatever they printed is saved to val.