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

Re: weird behaviour of quotes in dash variable assignments



On 2020-09-20 18:18, Gary Dale wrote:
On 2020-09-20 20:36, David Christensen wrote:

The environments are identical.

Have you tried '#!/bin/sh' ?

That's my shebang line.

Have you tried single quotes?

Wouldn't want to. Single quotes alter the behaviour.

Double quotes, single quotes, and no quotes have the same behavior on my machine:

2020-09-20 19:50:55 dpchrist@tinkywinky ~/sandbox/sh
$ cat debian-user-20200920-1727-gary-dale.sh
#!/bin/sh

doublequote="/root/clamscan-report"
echo $doublequote

singlequote='/root/clamscan-report'
echo $singlequote

noquote='/root/clamscan-report'
echo $noquote

2020-09-20 19:53:02 dpchrist@tinkywinky ~/sandbox/sh
$ /bin/sh -x debian-user-20200920-1727-gary-dale.sh
+ doublequote=/root/clamscan-report
+ echo /root/clamscan-report
/root/clamscan-report
+ singlequote=/root/clamscan-report
+ echo /root/clamscan-report
/root/clamscan-report
+ noquote=/root/clamscan-report
+ echo /root/clamscan-report
/root/clamscan-report


Please run the above script and the following commands, and post your console session -- prompts, commands, output:

2020-09-20 19:52:29 dpchrist@tinkywinky ~/sandbox/sh
$ cat /etc/debian_version
9.13

2020-09-20 19:52:38 dpchrist@tinkywinky ~/sandbox/sh
$ uname -a
Linux tinkywinky 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05) x86_64 GNU/Linux

2020-09-20 19:52:43 dpchrist@tinkywinky ~/sandbox/sh
$ dpkg-query --show dash
dash	0.5.8-2.4

2020-09-20 19:52:51 dpchrist@tinkywinky ~/sandbox/sh
$ dpkg --verify dash

2020-09-20 19:52:56 dpchrist@tinkywinky ~/sandbox/sh
$ sha256sum /bin/sh
e803088e7938b328b0511957dcd0dd7b5600ec1940010c64dbd3814e3d75495f  /bin/sh


David


Reply to: