Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #227233

Re: weird behaviour of quotes in dash variable assignments

From Gary Dale <gary@extremeground.com>
Newsgroups linux.debian.user
Subject Re: weird behaviour of quotes in dash variable assignments
Date 2020-09-22 03:10 +0200
Message-ID <AREYG-3kK-7@gated-at.bofh.it> (permalink)
References (5 earlier) <ARljj-8jW-1@gated-at.bofh.it> <ARsEa-44w-9@gated-at.bofh.it> <ARsXw-4qm-7@gated-at.bofh.it> <ARx18-6T1-13@gated-at.bofh.it> <ARAs1-zT-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 2020-09-21 16:18, David Christensen wrote:
> 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'.

The two servers are for different customers. I would not want to create 
a tunnel between them. Instead I have my normal ssh tunnels to each 
server from my workstation. However the script is only readable by root 
while my tunnels are for my non-root account. While I could copy the 
file to my non-root account (while root), chown it, copy it to my 
workstation then to the other server, where I'd move it to /root, that's 
a lot more work than cat, copy, paste, save.

Again, the method I used should not have created any changes in the 
script that would affect its operation. And to date I've seen no 
indication that it did. I still don't know why the script was leaving 
the quotes in nor why it started working.

Back to linux.debian.user | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

weird behaviour of quotes in bash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-21 00:10 +0200
  Re: weird behaviour of quotes in bash variable assignments The Wanderer <wanderer@fastmail.fm> - 2020-09-21 00:20 +0200
    Re: weird behaviour of quotes in bash variable assignments David Christensen <dpchrist@holgerdanske.com> - 2020-09-21 02:40 +0200
      Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-21 03:20 +0200
        Re: weird behaviour of quotes in dash variable assignments David Christensen <dpchrist@holgerdanske.com> - 2020-09-21 05:00 +0200
          Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-21 06:00 +0200
            Re: weird behaviour of quotes in dash variable assignments David Christensen <dpchrist@holgerdanske.com> - 2020-09-21 06:20 +0200
        Re: weird behaviour of quotes in dash variable assignments David <bouncingcats@gmail.com> - 2020-09-21 05:40 +0200
          Re: weird behaviour of quotes in dash variable assignments David Christensen <dpchrist@holgerdanske.com> - 2020-09-21 06:10 +0200
            Re: weird behaviour of quotes in dash variable assignments Cindy Sue Causey <butterflybytes@gmail.com> - 2020-09-21 14:00 +0200
              Re: weird behaviour of quotes in dash variable assignments Greg Wooledge <wooledg@eeg.ccf.org> - 2020-09-21 14:20 +0200
                Re: weird behaviour of quotes in dash variable assignments David Wright <deblis@lionunicorn.co.uk> - 2020-09-21 16:40 +0200
                Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-22 03:00 +0200
                Re: weird behaviour of quotes in dash variable assignments David Wright <deblis@lionunicorn.co.uk> - 2020-09-22 15:40 +0200
                Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-22 19:40 +0200
                Re: weird behaviour of quotes in dash variable assignments David Wright <deblis@lionunicorn.co.uk> - 2020-09-23 17:50 +0200
                Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-21 18:40 +0200
                Re: weird behaviour of quotes in dash variable assignments Greg Wooledge <wooledg@eeg.ccf.org> - 2020-09-21 18:50 +0200
                Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-21 19:00 +0200
                Re: weird behaviour of quotes in dash variable assignments Greg Wooledge <wooledg@eeg.ccf.org> - 2020-09-21 19:20 +0200
                Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-21 20:50 +0200
                Re: weird behaviour of quotes in dash variable assignments David Wright <deblis@lionunicorn.co.uk> - 2020-09-22 02:40 +0200
                Re: weird behaviour of quotes in dash variable assignments David Christensen <dpchrist@holgerdanske.com> - 2020-09-21 22:20 +0200
                Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-22 03:10 +0200
                Re: weird behaviour of quotes in dash variable assignments David Christensen <dpchrist@holgerdanske.com> - 2020-09-22 06:30 +0200
                Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-22 22:10 +0200
                SSH agent forwarding (was: weird behaviour of quotes in dash variable  assignments) David Christensen <dpchrist@holgerdanske.com> - 2020-09-23 00:40 +0200
        Re: weird behaviour of quotes in dash variable assignments Greg Wooledge <wooledg@eeg.ccf.org> - 2020-09-21 14:00 +0200
          Re: weird behaviour of quotes in dash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-21 18:40 +0200
    Re: weird behaviour of quotes in bash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-21 03:10 +0200
  Re: weird behaviour of quotes in bash variable assignments <tomas@tuxteam.de> - 2020-09-21 10:00 +0200
    Re: weird behaviour of quotes in bash variable assignments David Christensen <dpchrist@holgerdanske.com> - 2020-09-21 22:20 +0200
      Re: weird behaviour of quotes in bash variable assignments Greg Wooledge <wooledg@eeg.ccf.org> - 2020-09-21 22:30 +0200
        Re: weird behaviour of quotes in bash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-21 23:30 +0200
          Re: weird behaviour of quotes in bash variable assignments Andrei POPESCU <andreimpopescu@gmail.com> - 2020-09-22 07:50 +0200
            Re: weird behaviour of quotes in bash variable assignments Gary Dale <gary@extremeground.com> - 2020-09-22 22:40 +0200
              Re: weird behaviour of quotes in bash variable assignments Greg Wooledge <wooledg@eeg.ccf.org> - 2020-09-22 23:00 +0200
              Re: weird behaviour of quotes in bash variable assignments Andrei POPESCU <andreimpopescu@gmail.com> - 2020-09-23 12:00 +0200

csiph-web