0

I have this little script in bash and i have a weird error :

#!/usr/bin/env bash

function fun1(){
  message = "coucou"
  echo $message
}

function fun2(){
  local res=$(fun1)
  echo $res
}

fun1
fun2

The output is :

./test.sh ligne 4: message: command not found

Seem this ligne is a problem but don't know why ...

message = "coucou"
mpgn
  • 7,121
  • 9
  • 67
  • 100

1 Answers1

3

You have spaces in your assignment:

  message = "coucou"

So it treats message as a command and = and "coucou" as arguments to it. Hence, the error. change it to:

  message="coucou"
P.P
  • 117,907
  • 20
  • 175
  • 238