Pregunta

I'm trying execute a set of commands in a new bash session:

exec bash <<- EOF
   ln -snf $JDK_REPO'/jdk'$1 $CURRENT;
   JAVA_HOME=$(readlink -f $CURRENT);
   echo $JAVA_HOME;
   export PATH= $JAVA_HOME/bin:$PATH;
   exec usejdk 
   EOF

I get this error :

 warning: here-document at line 46 delimited by end-of-file (wanted `EOF')

I tried to debug it with whatswrongwithmyscript, I get :

Use <<- instead of << if you want to indent the end token.

Any suggestion to execute a set of commands in a new bash instance ?

¿Fue útil?

Solución

doing it this way works for me:

cmd="
   ln -snf $JDK_REPO'/jdk'$1 $CURRENT;
   JAVA_HOME=$(readlink -f $CURRENT);
   echo $JAVA_HOME;
   export PATH= $JAVA_HOME/bin:$PATH;
   exec usejdk"
bash <<< "$cmd"

The bash <<< "$cmd" is equivalent to echo "$cmd" | bash or bash -c "$cmd"

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top