[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: weird behaviour of quotes in bash variable assignments



On Sun, Sep 20, 2020 at 05:27:49PM -0400, Gary Dale wrote:
> I have the same bash script on two different Debian/Buster AMD64
> servers. However on one it refused to run. I tracked it down quickly
> to a variable substitution problem.
> 
> The line causing the problem reads: report="/root/clamscan-report"
> 
> On one server  echo $report  prints  /root/clamscan-report  while on
> the other it prints  "/root/clamscan-report".
> 
> Needless to say clamscan can't print to the latter. I fixed it by
> removing the quotes on the one server but now the scripts are
> different between the two servers, which isn't what I want. More
> importantly, I don't understand why it refuses to remove the quotes.
> 
> Where does this behaviour (keeping the quotes) get set?

What does the builtin "shopt" say? Especially the value of `compat42'
is involved in quote removal.

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


Reply to: