On 2020-09-21 09:34, 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).
That process may have changed the file in invisible ways. Use
hexdump(1) to check for differences. See below examples.
Use scp(1), rsync(1), sshfs(1), a networked version control system such
as cvs(1), etc., to copy files accurately.
On 2020-09-21 09:59, Gary Dale wrote:
> Most shells (all that I am aware of) treat tabs and blanks as generic
> white space - not relevant to the execution of the code.
"I guess so". (Obviously, I am not a dash(1) shell scripting expert.)
I have greater confidence in my ability to copy files accurately, and
thereby eliminate one set of potential problems. If the problem does
turn out to be spaces and tabs in code, hopefully the script will
misbehave consistently and I will figure it out.
David
2020-09-21 13:01:00 dpchrist@tinkywinky ~
$ cat /etc/debian_version ; uname -a ; dpkg-query --show xfce4 ;
dpkg-query --show vim
9.13
Linux tinkywinky 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05)
x86_64 GNU/Linux
xfce4 4.12.3
vim 2:8.0.0197-4+deb9u3
Test #1 -- copy and paste from cat(1) to vim(1)
===============================================
Terminal #1
-----------
2020-09-21 12:13:03 dpchrist@tinkywinky ~
$ vi foo
2020-09-21 12:13:54 dpchrist@tinkywinky ~
$ cat foo
I am foo!
leading tab
Foo on you!
trailing tab
2020-09-21 12:13:57 dpchrist@tinkywinky ~
$ hexdump foo
00000000 49 20 61 6d 20 66 6f 6f 21 0a 09 6c 65 61 64 69 |I am
foo!..leadi|
00000010 6e 67 20 74 61 62 0a 46 6f 6f 20 6f 6e 20 79 6f |ng tab.Foo
on yo|
00000020 75 21 0a 74 72 61 69 6c 69 6e 67 20 74 61 62 09 |u!.trailing
tab.|
00000030 0a |.|
00000031
<mouse drag and highlight cat(1) output>
Terminal #2
-----------
2020-09-21 12:01:15 dpchrist@tinkywinky ~
$ vi bar
<mouse middle click and paste text into edit buffer, save, exit>
2020-09-21 12:15:07 dpchrist@tinkywinky ~
$ cat bar
I am foo!
leading tab
Foo on you!
trailing tab
2020-09-21 12:16:06 dpchrist@tinkywinky ~
$ hexdump bar
00000000 49 20 61 6d 20 66 6f 6f 21 0a 09 6c 65 61 64 69 |I am
foo!..leadi|
00000010 6e 67 20 74 61 62 0a 46 6f 6f 20 6f 6e 20 79 6f |ng tab.Foo
on yo|
00000020 75 21 0a 74 72 61 69 6c 69 6e 67 20 74 61 62 09 |u!.trailing
tab.|
00000030 0a 0a |..|
00000032
Result: there is an extra newline at the end of 'bar'.
Test #2 -- copy and paste from less(1) to vim(1)
================================================
Terminal #3
-----------
2020-09-21 12:25:49 dpchrist@tinkywinky ~
$ less foo
<mouse drag and highlight text within less(1) display>
Terminal #4
-----------
2020-09-21 12:26:25 dpchrist@tinkywinky ~
$ vi baz
<mouse middle click and paste text into edit buffer, save, exit>
2020-09-21 13:06:14 dpchrist@tinkywinky ~
$ cat baz
I am foo!
leading tab
Foo on you!
trailing tab
2020-09-21 13:06:16 dpchrist@tinkywinky ~
$ hexdump baz
00000000 49 20 61 6d 20 66 6f 6f 21 0a 20 20 20 20 20 20 |I am foo!.
|
00000010 20 20 6c 65 61 64 69 6e 67 20 74 61 62 0a 46 6f | leading
tab.Fo|
00000020 6f 20 6f 6e 20 79 6f 75 21 0a 74 72 61 69 6c 69 |o on
you!.traili|
00000030 6e 67 20 74 61 62 20 20 20 20 0a 0a |ng tab ..|
0000003c
Result: Both tabs have been replaced with spaces and there is an extra
newline at the end of 'baz'.