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

Re: weird behaviour of quotes in bash variable assignments



On 2020-09-22 01:48, Andrei POPESCU wrote:
On Lu, 21 sep 20, 17:22:26, Gary Dale wrote:
I presented the line that failed, copied and pasted from the Konsole
session. What more do you want, other than to complain?
In such cases it is best to attach[1] the smallest complete[2] script
demonstrating the behaviour.

Based on the information provided so far it is highly likely the issue
was caused by some detail you omitted because you decided it is not
relevant.

[1] as demonstrated, copy-pasting can alter content
[2] as discussed, the shebang line can make a big difference

Kind regards,
Andrei

Your first point makes it impossible for me to present anything because this list doesn't (AFAIK) allow attachments. I can only present a copy-pasted example.

Your second point would assume that I'm using a non-standard shebang. I use #!/bin/sh unless I need something that is only available in bash (can't recall a case of that). Moreover, the consensus seems to be that if there was an error on the shebang line, the default shell would be used.

The smallest complete script then is

report=”/root/clamscan-report”
echo $report

but as I explained, that works on one server but not the other. Hence my question wasn't "what's wrong with this line" but rather "how do I change the behaviour". I'm not expecting anyone else to be able to reproduce the problem because I can't even do it except on the one server.

And to do that, I didn't even need the shebang line. I could enter the line at the command prompt then echo it and see the same result. Since it wasn't the shebang line, and didn't even require being in a script, why should I have included the shebang line?


Reply to: