rc scripting trouble with quotes

Murk Fletcher murk.fletcher at gmail.com
Tue Jun 7 12:04:30 UTC 2016


Hi!

How do I access a variable inside quotes? Right now I'm having some
difficulties:

stop_cmd="cd ${myapp} && \
  ${myapp} stop && \
  kill -9 `cat ${myapp}/tmp/pids/example.pid`"

Returns:

cat: ${myapp}/tmp/pids/example.pid: No such file or directory

I hear it would work better with double quotes, but that would add a
double-double quote at the end:

stop_cmd="cd ${myapp} && \
  ${myapp} stop && \
  kill -9 "$(cat -- ${myapp}/tmp/pids/example.pid)""

Is there a way I could wrap the contents of `stop_cmd` inside a function or
something?

Thanks!

--Murk

https://freebsd.org/doc/en/articles/rc-scripting/rcng-dummy.html


More information about the freebsd-questions mailing list