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

Re: weird behaviour of quotes in dash variable assignments




On 2020-09-21 08:18, Greg Wooledge wrote:
On Mon, Sep 21, 2020 at 07:55:45AM -0400, Cindy Sue Causey wrote:
'…' and "…" are known as neutral, vertical, straight, typewriter,
dumb, or ASCII quotation marks.

‘…’ and “…” are known as typographic, curly, curved, book, or smart
quotation marks.
Yes.  This is one of the possible causes for the behavior the OP was
reporting.  But if this is true, then it reveals that they were lying
when they claimed that the scripts were the same on both servers.

They function differently somehow, too. I don't remember if that
difference in functioning was by design or just bad placement in a
file. Maybe it's about the above reference to ASCII. Discovering the
difference between them was another one of those ah-ha moments tripped
over via a terminal window.
Remember, the computer can't actually *see* the characters the way
that you do.  To the computer, every character is just a number, or
a sequence of numbers.

To bash, the character " (byte value 0x22) has a special meaning, and
so does the character ' (byte value 0x27).  However, the characters
“ (byte values 0xe2809c) and ” (byte values 0xe2809d) have no special
meaning.  They're just some random data that the shell doesn't interpret.

unicorn:~$ x="foo"; echo "$x"
foo
unicorn:~$ x='foo'; echo "$x"
foo
unicorn:~$ x=“foo”; echo "$x"
“foo”

To beat a dead horse some more, if *this* was the OP's problem, then they
told multiple lies about it.  They did not paste the actual failing line
from the failing script (probably retyped it instead), and they did not
ACTUALLY COMPARE the two scripts to see whether they were different,
instead simply ASSUMING that the two scripts were identical, even though
they very clearly weren't.

An actual troubleshooting would have done something like using md5sum
on the script on each machine, and pasting the md5sum commands (including
the full script pathname) and their output to the mailing list.  Openness.

Or, hell, even "ls -l /full/pathname" would probably have revealed that
the scripts were not the same SIZE.  That would also have shown immediately
that the scripts were not "the same".

As an FYI, the scripts were the same on both servers because I had ssh sessions on both and copy/pasted the script from one to the other. (cat <script> on server 1, then use Konsole's copy and paste to select and paste it into nano on server 2).


Reply to: