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

Re: weird behaviour of quotes in dash variable assignments



On Mon, Sep 21, 2020 at 12:34:20PM -0400, Gary Dale wrote:
> 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).

Copy and paste doesn't always preserve the actual contents of a file.
What you get depends on several factors, including the behavior of the
terminal emulator that you're copying from.  Tabs may be converted to
spaces, and I have no idea what other changes may occur.

As a demonstration for myself, just now, I performed the following
experiment in both rxvt-unicode and xterm, on Debian 10:

1) Run the command:  printf 'a\tb\n'
2) Run the command:  hd
3) Highlight the line containing the output of the first command, and paste
   it into the terminal, to be read by hd.
4) Press Ctrl-D.

On rxvt-unicode, I get this output:

00000000  61 09 62 0a                                       |a.b.|
00000004

On xterm, I get this output:

00000000  61 20 20 20 20 20 20 20  62 0a                    |a       b.|
0000000a

If your original script contained non-breaking spaces, or curly quotes,
or literal tabs, or who knows what else, then there's a nonzero chance
it will be altered by the copy/paste.

This is why you need to *verify* that the two scripts are the same, not
just assume that pasting did what you thought it did.


Reply to: