Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jun 2016 14:04:27 +0200
From:      Murk Fletcher <murk.fletcher@gmail.com>
To:        User Questions <freebsd-questions@freebsd.org>
Subject:   rc scripting trouble with quotes
Message-ID:  <CAH=3fONuy_afgSHGMO7YafN2cX8O9V9ULV3-%2BQq86eRxaJXysw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAH=3fONuy_afgSHGMO7YafN2cX8O9V9ULV3-%2BQq86eRxaJXysw>