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


Groups > linux.debian.user > #227892 > unrolled thread

rsync --delete

Started byMike McClain <mike.junk.46@att.net>
First post2020-10-17 00:30 +0200
Last post2020-10-19 14:10 +0200
Articles 20 on this page of 40 — 15 participants

Back to article view | Back to linux.debian.user


Contents

  rsync --delete Mike McClain <mike.junk.46@att.net> - 2020-10-17 00:30 +0200
    Re: rsync --delete Klaus Singvogel <deb-user-ml@singvogel.net> - 2020-10-17 00:40 +0200
      Re: rsync --delete Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-19 13:40 +0200
    Re: rsync --delete ellanios82 <ellanios82@gmail.com> - 2020-10-17 00:40 +0200
    Re: rsync --delete Charles Curley <charlescurley@charlescurley.com> - 2020-10-17 04:10 +0200
    Re: rsync --delete Will Mengarini <seldon@eskimo.com> - 2020-10-17 08:40 +0200
      Re: rsync --delete Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-19 13:50 +0200
    Re: rsync --delete <tomas@tuxteam.de> - 2020-10-17 10:40 +0200
      Re: rsync --delete David <bouncingcats@gmail.com> - 2020-10-17 14:20 +0200
        Re: rsync --delete <tomas@tuxteam.de> - 2020-10-17 15:30 +0200
      Re: rsync --delete Mike McClain <mike.junk.46@att.net> - 2020-10-17 20:30 +0200
        Re: rsync --delete Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-19 13:50 +0200
      Re: rsync --delete Andrei POPESCU <andreimpopescu@gmail.com> - 2020-10-18 12:50 +0200
    Re: rsync --delete Andy Smith <andy@strugglers.net> - 2020-10-17 17:30 +0200
    Re: rsync --delete David Christensen <dpchrist@holgerdanske.com> - 2020-10-18 00:10 +0200
      Re: rsync --delete Mike McClain <mike.junk.46@att.net> - 2020-10-19 01:40 +0200
      Re: rsync --delete Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-19 14:00 +0200
        Re: rsync --delete Mike McClain <mike.junk.46@att.net> - 2020-10-19 21:10 +0200
          Re: rsync --delete Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-19 21:20 +0200
            Re: rsync --delete Tixy <tixy@yxit.co.uk> - 2020-10-19 23:20 +0200
              Re: rsync --delete David Christensen <dpchrist@holgerdanske.com> - 2020-10-20 05:10 +0200
                Re: rsync --delete Tixy <tixy@yxit.co.uk> - 2020-10-20 09:30 +0200
                  Re: rsync --delete David <bouncingcats@gmail.com> - 2020-10-20 10:00 +0200
                    Re: rsync --delete Tixy <tixy@yxit.co.uk> - 2020-10-20 10:20 +0200
                Re: rsync --delete Andrei POPESCU <andreimpopescu@gmail.com> - 2020-10-20 11:10 +0200
          Re: rsync --delete David <bouncingcats@gmail.com> - 2020-10-19 23:20 +0200
        Re: rsync --delete David Christensen <dpchrist@holgerdanske.com> - 2020-10-20 05:20 +0200
          Re: rsync --delete David <bouncingcats@gmail.com> - 2020-10-20 06:10 +0200
            Re: rsync --delete Nicolas George <george@nsup.org> - 2020-10-20 12:10 +0200
          Re: rsync --delete Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-20 13:50 +0200
            Re: rsync --delete The Wanderer <wanderer@fastmail.fm> - 2020-10-20 14:50 +0200
              Re: rsync --delete Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-20 15:10 +0200
                Re: rsync --delete The Wanderer <wanderer@fastmail.fm> - 2020-10-20 15:50 +0200
                  Re: rsync --delete Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-20 16:10 +0200
      define (or translate, or substitute for) "interpolate": Re: rsync --delete rhkramer@gmail.com - 2020-10-19 14:30 +0200
        Re: define (or translate, or substitute for) "interpolate": Re: rsync --delete rhkramer@gmail.com - 2020-10-19 14:50 +0200
        Re: define (or translate, or substitute for) "interpolate": Re:  rsync --delete <tomas@tuxteam.de> - 2020-10-19 15:00 +0200
          Re: define (or translate, or substitute for) "interpolate": Re: rsync --delete rhkramer@gmail.com - 2020-10-20 02:10 +0200
            Re: define (or translate, or substitute for) "interpolate": Re: rsync  --delete David Christensen <dpchrist@holgerdanske.com> - 2020-10-20 05:50 +0200
    Re: rsync --delete Greg Wooledge <wooledg@eeg.ccf.org> - 2020-10-19 14:10 +0200

Page 2 of 2 — ← Prev page 1 [2]


#228000

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2020-10-20 05:10 +0200
Message-ID<B1Qc9-3Nk-1@gated-at.bofh.it>
In reply to#227990
On 2020-10-19 14:12, Tixy wrote:
> On Mon, 2020-10-19 at 15:16 -0400, Greg Wooledge wrote:

>> https://mywiki.wooledge.org/BashFAQ/105
> 
> NOOOOOOOOOOO!!!! ;-)
> 
> Excuse me while I go grep 'set -e' -R ...


2020-10-19 20:01:44 dpchrist@tinkywinky ~
$ cat /etc/debian_version ; uname -a
9.13
Linux tinkywinky 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05) 
x86_64 GNU/Linux

2020-10-19 20:02:17 dpchrist@tinkywinky ~
$ IFS=: && for p in $PATH; do egrep -r 'set (-e|-o errexit)' $p; done
/usr/bin/debrelease:set -e
/usr/bin/pts-subscribe:set -e
/usr/bin/start-pulseaudio-x11:set -e
/usr/bin/os-prober:set -e
/usr/bin/deb-reversion:set -eu
/usr/bin/nmudiff:set -e
/usr/bin/dpkg-maintscript-helper:set -e
/usr/bin/debrepro:set -eu
/usr/bin/debrepro:    echo 'set -eu'
/usr/bin/dpkg-genbuilddeps:set -e
/usr/bin/p7zip:#    - remove `"$?" != 0 ' checks that do not work with 
`set -e'
/usr/bin/p7zip:set -e
/usr/bin/dscextract:set -eu
/usr/bin/cvs-debi:set -e
/usr/bin/wnpp-alert:set -e
/usr/bin/cvs-debrelease:set -e
/usr/bin/wnpp-check:set -e
/usr/bin/debrsign:set -e
/usr/bin/diff2patches:set -e
/usr/bin/linux-boot-prober:set -e
/usr/bin/migrate-pubring-from-classic-gpg:set -e
/usr/bin/rebuild-gcj-db:set -e
/usr/bin/ucf:set -e
/usr/bin/ucf:	    set -e
/usr/bin/ucf:	    set -e
/usr/bin/debsign:set -e
/usr/bin/archpath:set -e
/usr/bin/unmkinitramfs:set -eu
/usr/bin/cowpoke:set -e
/usr/bin/cowpoke:	    set -eo pipefail
/usr/bin/whodepends:set -e
/usr/bin/edit-patch:set -e
/usr/bin/apt-key:set -e
/usr/bin/mergechanges:set -e
/usr/bin/ssh-argv0:set -e
/usr/bin/x11perfcomp:set -e
/usr/bin/lcf:set -e
/usr/bin/lsinitramfs:set -eu
/usr/bin/getbuildlog:set -e
/usr/bin/ucfr:set -e
/usr/bin/ucfr:	set -e
/usr/bin/ucfr:	set -e
/bin/which:set -ef


David

[toc] | [prev] | [next] | [standalone]


#228004

FromTixy <tixy@yxit.co.uk>
Date2020-10-20 09:30 +0200
Message-ID<B1UfL-6c7-1@gated-at.bofh.it>
In reply to#228000
On Mon, 2020-10-19 at 20:04 -0700, David Christensen wrote:
[...]
> $ IFS=: && for p in $PATH; do egrep -r 'set (-e|-o errexit)' $p; done
[...]
> /usr/bin/p7zip:#    - remove `"$?" != 0 ' checks that do not work with 
> `set -e'

:-)

I see in the Bash FAQ [1] there is an alternative opinion on the matter
expressed...

"rking's personal recommendation is to go ahead and use set -e, but
beware of possible gotchas. It has useful semantics, so to exclude it
from the toolbox is to give into FUD."

[1] https://mywiki.wooledge.org/BashFAQ/105

-- 
Tixy

[toc] | [prev] | [next] | [standalone]


#228006

FromDavid <bouncingcats@gmail.com>
Date2020-10-20 10:00 +0200
Message-ID<B1UIN-6lL-3@gated-at.bofh.it>
In reply to#228004
On Tue, 20 Oct 2020 at 18:27, Tixy <tixy@yxit.co.uk> wrote:
> On Mon, 2020-10-19 at 20:04 -0700, David Christensen wrote:

> I see in the Bash FAQ [1] there is an alternative opinion on the matter
> expressed...

> "rking's personal recommendation is to go ahead and use set -e, but
> beware of possible gotchas. It has useful semantics, so to exclude it
> from the toolbox is to give into FUD."

> [1] https://mywiki.wooledge.org/BashFAQ/105

I am familiar with the names GreyCat and geirha and lhunath and koalaman
because they have made unmissable contributions to shells and shell
scripting, supporting and documenting and educating shell users
for decades.

You can find some of their work by internet search on each of those
names: 'shell GreyCat' 'shell geirha' etc.

I searched 'shell rking' and found nothing.

Does anyone know who rking mentioned there is?

[toc] | [prev] | [next] | [standalone]


#228008

FromTixy <tixy@yxit.co.uk>
Date2020-10-20 10:20 +0200
Message-ID<B1V29-6HC-1@gated-at.bofh.it>
In reply to#228006
On Tue, 2020-10-20 at 18:49 +1100, David wrote:
> I am familiar with the names GreyCat and geirha and lhunath and
> koalaman
> because they have made unmissable contributions to shells and shell
> scripting, supporting and documenting and educating shell users
> for decades.
> 
> You can find some of their work by internet search on each of those
> names: 'shell GreyCat' 'shell geirha' etc.
> 
> I searched 'shell rking' and found nothing.
> 
> Does anyone know who rking mentioned there is?

The only R King I know of is Russell King, kernel maintainer for the
32-bit ARM architecture.

-- 
Tixy

[toc] | [prev] | [next] | [standalone]


#228009

FromAndrei POPESCU <andreimpopescu@gmail.com>
Date2020-10-20 11:10 +0200
Message-ID<B1VOy-7d9-13@gated-at.bofh.it>
In reply to#228000

[Multipart message — attachments visible in raw view] — view raw

On Lu, 19 oct 20, 20:04:07, David Christensen wrote:
> On 2020-10-19 14:12, Tixy wrote:
> > On Mon, 2020-10-19 at 15:16 -0400, Greg Wooledge wrote:
> 
> > > https://mywiki.wooledge.org/BashFAQ/105
> > 
> > NOOOOOOOOOOO!!!! ;-)
> > 
> > Excuse me while I go grep 'set -e' -R ...
> 
> 
> 2020-10-19 20:01:44 dpchrist@tinkywinky ~
> $ cat /etc/debian_version ; uname -a
> 9.13
> Linux tinkywinky 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05) x86_64
> GNU/Linux
> 
> 2020-10-19 20:02:17 dpchrist@tinkywinky ~
> $ IFS=: && for p in $PATH; do egrep -r 'set (-e|-o errexit)' $p; done

[snipped various scripts from /usr/bin]

It's much "worse" than that, even the Debian Policy Manual strongly 
recommends using 'set -e' in package maintainer scripts.

https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html

While the package maintainer scripts are arguably a somewhat special 
case, the rough consensus in Debian appears to be that 'set -e' should 
always be used in shell scripts (as the Debian Policy suggests).

See also the thread starting here:
https://lists.debian.org/debian-devel/2018/07/msg00199.html

Kind regards,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser

[toc] | [prev] | [next] | [standalone]


#227991

FromDavid <bouncingcats@gmail.com>
Date2020-10-19 23:20 +0200
Message-ID<B1KJs-oU-5@gated-at.bofh.it>
In reply to#227985
On Tue, 20 Oct 2020 at 06:09, Mike McClain <mike.junk.46@att.net> wrote:

> On a different subject, my guess is that your insistence on quoting
> variables and using arrays for multi-part parameters is that doing so
> as a habit covers the times when a string variable will not expand as
> expected while an array will.

> Please correct me if I'm mis-reading things.

Below is another demo of why it is recommended to always quote shell
parameter expansions as standard practice, unless:
1) not-quoting the parameter is *required* for some reason;
2) the situation is fully controlled;
3) the shell parsing and expansion algorithms and execution sequence
   are completely understood.

$ mkdir demo
$ cd demo
$ touch some files in this directory
$ ls
directory  files  in  some  this
$ foo="* * * important * * *"
$ echo $foo
directory files in some this directory files in some this directory
files in some this important directory files in some this directory
files in some this directory files in some this

[toc] | [prev] | [next] | [standalone]


#228001

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2020-10-20 05:20 +0200
Message-ID<B1QlQ-3Rv-3@gated-at.bofh.it>
In reply to#227967
On 2020-10-19 04:55, Greg Wooledge wrote:
> On Sat, Oct 17, 2020 at 03:01:13PM -0700, David Christensen wrote:
>> I try to use all lower case letters for variable names and all upper case
>> letters for constants.
> 
> ALL_UPPER_CASE is reserved for internal shell variables, and environment
> variables.

Please provide a citation (for Bourne shell scripts).


> If you abuse it for "constants" as well, on your head be it.  You must
> take care to ensure that your ALL_CAPS variable does not collide with
> any internal shell variables, or environment variables.

Yes.


>> I use braces whenever evaluating a variable -- '${Params}'.  I forget the
>> details why, but I do recall that this practice is important.
> 
> It isn't.  It's entirely stylistic.

https://stackoverflow.com/questions/8748831/when-do-we-need-curly-braces-around-shell-variables


>> I don't use Bourne arrays, and I barely understand how the shell
> 
> Bourne shell does not have arrays.  Neither does POSIX shell.
> 
>> interpolates lists and preserves items containing whitespace.  When I can't
>> figure it out, I switch to Perl.
> 
> OK.

No wonder I don't use arrays (or Bash) in shell scripts.


>>> cd /home/mike
>>
>> I prefer scripts that I can run from anywhere.
> 
> ... hence, the cd inside the script.  Doesn't matter where you call it
> from, as long as the script cd's to the right location to do its work,
> **AND VERIFIES THAT THE cd ACTUALLY WORKED**.

Another reason why I use 'set -e':

2020-10-19 20:06:06 dpchrist@tinkywinky ~/sandbox/sh
$ cat /etc/debian_version ; uname -a
9.13
Linux tinkywinky 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05) 
x86_64 GNU/Linux

2020-10-19 20:06:08 dpchrist@tinkywinky ~/sandbox/sh
$ cat set-e.sh
#!/bin/sh
set -x
cd /no/such/directory
echo $?
set -e
cd /another/bad/directory
echo $?

2020-10-19 20:06:14 dpchrist@tinkywinky ~/sandbox/sh
$ /bin/sh set-e.sh
+ cd /no/such/directory
set-e.sh: 3: cd: can't cd to /no/such/directory
+ echo 2
2
+ set -e
+ cd /another/bad/directory
set-e.sh: 6: cd: can't cd to /another/bad/directory


>> If the script must change the working directory, I would display that --
>> 'set -x', 'cd ...', and 'set +x'.
> 
> For god's sake, why?

Sometimes I debug a script by opening another terminal and entering the 
commands that the script executed.

Sometimes I tee(1) the output of script to a log file so I have a record 
of what the script did.


>> I use 'set -e'
> 
> NOOOOOOOOOOO!!!!

On 2020-10-19 12:16, Greg Wooledge wrote:

 > https://mywiki.wooledge.org/BashFAQ/105

I am sorry, but your article does not convince me to not set 'errexit' 
in my Bourne shell scripts.  If and when I do need to deal with exit 
values manually, I will disable 'errexit' for the relevant stretch of 
code and then re-enable errexit afterwards.


On 2020-10-19 05:00, Greg Wooledge wrote:
 > using an explicit /usr/bin/rsync is sketchy at best.  You
 > should already have /usr/bin in your PATH

AIUI using absolute paths for tools in shell scripts is a security best 
practice -- it helps defend against attacks where PATH is compromised 
and/or trojaned system tools are inserted into directories at the front 
of PATH.

Using absolute paths for tools also means that the script will work when 
cron(8) runs it (or runs something that runs it).


David

[toc] | [prev] | [next] | [standalone]


#228003

FromDavid <bouncingcats@gmail.com>
Date2020-10-20 06:10 +0200
Message-ID<B1R8e-4nO-5@gated-at.bofh.it>
In reply to#228001
On Tue, 20 Oct 2020 at 14:11, David Christensen
<dpchrist@holgerdanske.com> wrote:
> On 2020-10-19 04:55, Greg Wooledge wrote:
> > On Sat, Oct 17, 2020 at 03:01:13PM -0700, David Christensen wrote:

> >> I try to use all lower case letters for variable names and all upper case
> >> letters for constants.

> > ALL_UPPER_CASE is reserved for internal shell variables, and environment
> > variables.

> Please provide a citation (for Bourne shell scripts).

Maybe POSIX.1-2017 is what you're asking for?

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap01.html
"""
POSIX.1-2017 defines a standard operating system interface and
environment, including a command interpreter (or "shell"), and
common utility programs to support applications portability at the
source code level.
"""

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
"""
Environment variable names used by the utilities in the Shell and Utilities
volume of POSIX.1-2017 consist solely of uppercase letters, digits, and
the <underscore> ( '_' )
[...]
The name space of environment variable names containing lowercase
letters is reserved for applications.
[...]
It is unwise to conflict with certain variables that are frequently exported
by widely used command interpreters and applications:
[...]
"""

[toc] | [prev] | [next] | [standalone]


#228011

FromNicolas George <george@nsup.org>
Date2020-10-20 12:10 +0200
Message-ID<B1WKB-7Ma-3@gated-at.bofh.it>
In reply to#228003

[Multipart message — attachments visible in raw view] — view raw

David (12020-10-20):
> > > ALL_UPPER_CASE is reserved for internal shell variables, and environment
> > > variables.
> 
> > Please provide a citation (for Bourne shell scripts).
> 
> Maybe POSIX.1-2017 is what you're asking for?
> 
> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap01.html
> """
> POSIX.1-2017 defines a standard operating system interface and
> environment, including a command interpreter (or "shell"), and
> common utility programs to support applications portability at the
> source code level.
> """
> 
> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
> """
> Environment variable names used by the utilities in the Shell and Utilities
> volume of POSIX.1-2017 consist solely of uppercase letters, digits, and
> the <underscore> ( '_' )
> [...]
> The name space of environment variable names containing lowercase
> letters is reserved for applications.
> [...]
> It is unwise to conflict with certain variables that are frequently exported
> by widely used command interpreters and applications:
> [...]
> """

Which says exactly the opposite of what was announced.

-- 
  A math teacher

[toc] | [prev] | [next] | [standalone]


#228017

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2020-10-20 13:50 +0200
Message-ID<B1Yjn-7a-11@gated-at.bofh.it>
In reply to#228001
On Mon, Oct 19, 2020 at 08:11:01PM -0700, David Christensen wrote:
> On 2020-10-19 05:00, Greg Wooledge wrote:
> > using an explicit /usr/bin/rsync is sketchy at best.  You
> > should already have /usr/bin in your PATH
> 
> AIUI using absolute paths for tools in shell scripts is a security best
> practice -- it helps defend against attacks where PATH is compromised and/or
> trojaned system tools are inserted into directories at the front of PATH.

It's not "best practice", and it does not provide any security against
a malevolent execution environment.  All it really does is introduce
failures when the location of a tool changes.  (See all the instances
of failures when new buster installations moved some tools from /bin
to /usr/bin, and scripts were updated to use things like /usr/bin/mkdir,
which then fails on *upgraded* buster systems.)

To illustrate why it doesn't provide any security protection:

unicorn:~$ function /bin/rm { echo "haha loser"; }
unicorn:~$ /bin/rm xyzzy
haha loser

Remember, bash can accept functions that are imported from the environment,
and bash's functions have an extremely liberal allowed set of characters.

Granted, that same feature/problem will not apply to non-bash scripts,
but even with a #!/bin/sh shebang, it's still common for systems to
have /bin/sh -> bash (even on Debian, it is a supported configuration).

> Using absolute paths for tools also means that the script will work when
> cron(8) runs it (or runs something that runs it).

You can set PATH at the top of the script.

In any case, /usr/bin should be in PATH, even in the most barebones cron
environment.  On Debian, crontab(5) says:

       Several environment variables are set up automatically by  the  cron(8)
       daemon.  SHELL is set to /bin/sh, and LOGNAME and HOME are set from the
       /etc/passwd  line  of  the   crontab's   owner.    PATH   is   set   to
       "/usr/bin:/bin".   HOME,  SHELL, and PATH may be overridden by settings
       in the crontab; LOGNAME is the user that the job is running  from,  and
       may not be changed.

[toc] | [prev] | [next] | [standalone]


#228020

FromThe Wanderer <wanderer@fastmail.fm>
Date2020-10-20 14:50 +0200
Message-ID<B1Zfs-GD-13@gated-at.bofh.it>
In reply to#228017

[Multipart message — attachments visible in raw view] — view raw

On 2020-10-20 at 07:49, Greg Wooledge wrote:

> On Mon, Oct 19, 2020 at 08:11:01PM -0700, David Christensen wrote:
>
>> On 2020-10-19 05:00, Greg Wooledge wrote:
>> > using an explicit /usr/bin/rsync is sketchy at best.  You
>> > should already have /usr/bin in your PATH
>> 
>> AIUI using absolute paths for tools in shell scripts is a security best
>> practice -- it helps defend against attacks where PATH is compromised and/or
>> trojaned system tools are inserted into directories at the front of PATH.
> 
> It's not "best practice", and it does not provide any security against
> a malevolent execution environment.  All it really does is introduce
> failures when the location of a tool changes.  (See all the instances
> of failures when new buster installations moved some tools from /bin
> to /usr/bin, and scripts were updated to use things like /usr/bin/mkdir,
> which then fails on *upgraded* buster systems.)
> 
> To illustrate why it doesn't provide any security protection:
> 
> unicorn:~$ function /bin/rm { echo "haha loser"; }
> unicorn:~$ /bin/rm xyzzy
> haha loser
> 
> Remember, bash can accept functions that are imported from the environment,
> and bash's functions have an extremely liberal allowed set of characters.

From a quick test, that seems to only matter if you actually import the
functions from the environment somehow.

$ cat /tmp/test-function-script.sh
#/bin/bash

/home/wanderer/bin/abecedarian.sh
$ function /home/wanderer/bin/abecedarian.sh { echo "nope"; }
$ abecedarian.sh
Usage: /home/wanderer/bin/abecedarian.sh /path/to/wordlist
$ /home/wanderer/bin/abecedarian.sh
nope
$ /tmp/test-function-script.sh
Usage: /home/wanderer/bin/abecedarian.sh /path/to/wordlist

If I'm parsing that correctly, the full-path invocation from within the
script doesn't seem to pick up the function definition from the outside
session.

I imagine there's probably some scenario that might occur outside of
intentional arrangement in which that definition would in fact be picked
up within the script; can you outline an exact reproducer scenario for
what you're thinking of?

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

[toc] | [prev] | [next] | [standalone]


#228021

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2020-10-20 15:10 +0200
Message-ID<B1ZyN-12w-5@gated-at.bofh.it>
In reply to#228020
On Tue, Oct 20, 2020 at 08:32:12AM -0400, The Wanderer wrote:
> $ cat /tmp/test-function-script.sh
> #/bin/bash
> 
> /home/wanderer/bin/abecedarian.sh

Incorrect shebang (missing the bang half).  Therefore, the shell that
actually gets used is unpredictable.  It depends on the caller.

If you call it *from* bash, then bash will be used.  If you call it from
anything else, you'll probably get either /bin/sh or an error.

> $ function /home/wanderer/bin/abecedarian.sh { echo "nope"; }
> $ abecedarian.sh
> Usage: /home/wanderer/bin/abecedarian.sh /path/to/wordlist
> $ /home/wanderer/bin/abecedarian.sh
> nope
> $ /tmp/test-function-script.sh
> Usage: /home/wanderer/bin/abecedarian.sh /path/to/wordlist
> 
> If I'm parsing that correctly, the full-path invocation from within the
> script doesn't seem to pick up the function definition from the outside
> session.

You also forgot to export the function.

[toc] | [prev] | [next] | [standalone]


#228023

FromThe Wanderer <wanderer@fastmail.fm>
Date2020-10-20 15:50 +0200
Message-ID<B20bv-1fk-1@gated-at.bofh.it>
In reply to#228021

[Multipart message — attachments visible in raw view] — view raw

On 2020-10-20 at 09:00, Greg Wooledge wrote:

> On Tue, Oct 20, 2020 at 08:32:12AM -0400, The Wanderer wrote:
>> $ cat /tmp/test-function-script.sh
>> #/bin/bash
>> 
>> /home/wanderer/bin/abecedarian.sh
> 
> Incorrect shebang (missing the bang half).  Therefore, the shell that
> actually gets used is unpredictable.  It depends on the caller.

Yeah - pure typo, sorry, I was dashing the script off quickly for the
test. (IIRC I actually had it initially as "#~/bin/bash', and mistakenly
deleted the ~ without adding the !.) I've re-tested with that changed,
and as expected (given that I was running it from bash to begin with) it
behaved identically.

>> $ function /home/wanderer/bin/abecedarian.sh { echo "nope"; }
>> $ abecedarian.sh
>> Usage: /home/wanderer/bin/abecedarian.sh /path/to/wordlist
>> $ /home/wanderer/bin/abecedarian.sh
>> nope
>> $ /tmp/test-function-script.sh
>> Usage: /home/wanderer/bin/abecedarian.sh /path/to/wordlist
>> 
>> If I'm parsing that correctly, the full-path invocation from within the
>> script doesn't seem to pick up the function definition from the outside
>> session.
> 
> You also forgot to export the function.

I was following the example from the two-liner in your previous post.
The notion that exporting would be needed for the effect to occur had
not occurred to me.

If I just prepend 'export ' to that function-definition line, I get a
syntax error "near unexpected token '}'". If I run a separate 'export
/home/wanderer/bin/abecedarian.sh' after defining the function, I get
"not a valid identifier". If I make that latter 'export -f [etc.]', I
get "cannot export". (By contrast, if I define a function which is not
syntactically an absolute path, 'export [function-name]' and 'export -f
[function-name]' report no errors.)

Maybe I'm still missing something, but so far I'm not seeing a way to
export this, so I still don't see a way it could get exposed inside the
script.

Looking at that, I wouldn't be surprised if it were to turn out that
bash prohibits function-name identifiers which have the form of an
absolute path (or maybe even a relative one containing a directory
reference) from being exported - possibly specifically to avoid this
type of attack.

The man page does say

>>> export returns an exit status of 0 unless an invalid option is
>>> encountered, one of the names is not a valid shell variable name, or -f
>>> is supplied with a name that is not a function.

so the possibility that '/path/to/location' is not a valid shell
variable name seems plausible. It's hard to search the man page for
those terms, because of all the unrelated hits that crop up (especially
with 'name'!), but I've given it a run-through and haven't found
anything that looks like a definition of what is and is not allowed in a
valid shell variable name.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

[toc] | [prev] | [next] | [standalone]


#228024

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2020-10-20 16:10 +0200
Message-ID<B20uR-1Bc-5@gated-at.bofh.it>
In reply to#228023
On Tue, Oct 20, 2020 at 09:42:26AM -0400, The Wanderer wrote:
> Maybe I'm still missing something, but so far I'm not seeing a way to
> export this, so I still don't see a way it could get exposed inside the
> script.

Oh, looks like a change was made.

wooledg:~$ bash-4.4
wooledg:~$ function /bin/echo { echo "good-bye world"; }
wooledg:~$ export -f /bin/echo
bash-4.4: export: /bin/echo: cannot export
wooledg:~$ exit
wooledg:~$ bash-3.2
wooledg:~$ function /bin/echo { echo "good-bye world"; }
wooledg:~$ export -f /bin/echo
wooledg:~$ exit
wooledg:~$ bash-4.3
wooledg:~$ function /bin/echo { echo "good-bye world"; }
wooledg:~$ export -f /bin/echo
wooledg:~$ 

Not sure whether that was an intentional change for security purposes, or
something accidental.  In any case, the change occurred between 4.3 and 4.4.

Anyway, hard-coding paths to common system tools is not a helpful
practice.  You're far better off just setting a safe PATH at the top
of your script, if you feel that you can't trust the execution
environment for some reason.

[toc] | [prev] | [next] | [standalone]


#227970 — define (or translate, or substitute for) "interpolate": Re: rsync --delete

Fromrhkramer@gmail.com
Date2020-10-19 14:30 +0200
Subjectdefine (or translate, or substitute for) "interpolate": Re: rsync --delete
Message-ID<B1Csy-3OF-1@gated-at.bofh.it>
In reply to#227926
On Saturday, October 17, 2020 06:01:13 PM David Christensen wrote:
> I don't use Bourne arrays, and I barely understand how the shell 
> interpolates lists and preserves items containing whitespace.  When I 
> can't figure it out, I switch to Perl.

I'm looking for an alternate thing to think of when I see the word interpolate 
-- I guess maybe interpret or substitute would be good ways for me to think 
about it (think when I see the word interpolate) (maybe see rant, below).

Rant (to ignore):

When I was in school, many years ago, I learned what I consider the 
"traditional" meaning of interpolate, typified by the following definitions / 
explanations found using google:

define: interpolate

Aside: I guess maybe the merriam-webster 1 b definition might be closest to the 
meaning intended, but I think the intention is more to substitute words.

`=
www.merriam-webster.com › dictionary › interpolate
1a : to alter or corrupt (something, such as a text) by inserting new or 
foreign matter. b : to insert (words) into a text or into a conversation. 2 : 
to insert between other things or parts : intercalate. 3 : to estimate values 
of (data or a function) between two known values. intransitive verb.

Interpolation - Wikipedia
en.wikipedia.org › wiki › Interpolation
In the mathematical field of numerical analysis, interpolation is a type of 
estimation, a method of ... variable, may be contrary to commonsense, i.e. to 
what is known about the experimental system which has generated the data 
points.

...

In computer graphics, interpolation is the creation of new values that lie 
between known values. ... Another example is when a video image in a low 
resolution is upscaled to display on a monitor with a higher resolution, the 
missing lines are created by interpolation.

Definition of interpolation | PCMag
www.pcmag.com › Encyclopedia › I
='

define interpolation computing

`=
What is interpolation in computer science?
In the context of live-action and computer animation, interpolation is 
inbetweening, or filling in frames between the key frames. It typically 
calculates the in-between frames through use of (usually) piecewise polynomial 
interpolation to draw images semi-automatically.

...

Interpolation (computer graphics) - Wikipedia
en.wikipedia.org › wiki › Interpolation_(computer_graph...
Search for: What is interpolation in computer science?
='

Don't know (really) why I bothered to write this, maybe just to express some 
frustration, or maybe by writing it I'll clear my brain slightly.  I guess I 
could have written it and never sent it -- I'm occasionally that disciplined, 
but not always ;-)

[toc] | [prev] | [next] | [standalone]


#227972 — Re: define (or translate, or substitute for) "interpolate": Re: rsync --delete

Fromrhkramer@gmail.com
Date2020-10-19 14:50 +0200
SubjectRe: define (or translate, or substitute for) "interpolate": Re: rsync --delete
Message-ID<B1CLT-3US-3@gated-at.bofh.it>
In reply to#227970
On Monday, October 19, 2020 08:30:36 AM rhkramer@gmail.com wrote:
> Oops, forgot to say that of course I recognize that language (and word
> meanings) evolve.
> 
> On Monday, October 19, 2020 08:29:32 AM rhkramer@gmail.com wrote:
> > On Saturday, October 17, 2020 06:01:13 PM David Christensen wrote:
> > > I don't use Bourne arrays, and I barely understand how the shell
> > > interpolates lists and preserves items containing whitespace.  When I
> > > can't figure it out, I switch to Perl.
> > 
> > I'm looking for an alternate thing to think of when I see the word
> > interpolate -- I guess maybe interpret or substitute would be good ways
> > for me to think about it (think when I see the word interpolate) (maybe
> > see rant, below).
> > 
> > Rant (to ignore):
> > 
> > When I was in school, many years ago, I learned what I consider the
> > "traditional" meaning of interpolate, typified by the following
> > definitions / explanations found using google:
> > 
> > define: interpolate
> > 
> > Aside: I guess maybe the merriam-webster 1 b definition might be closest
> > to the meaning intended, but I think the intention is more to substitute
> > words.
> > 
> > `=
> > www.merriam-webster.com › dictionary › interpolate
> > 1a : to alter or corrupt (something, such as a text) by inserting new or
> > foreign matter. b : to insert (words) into a text or into a conversation.
> > 2
> > 
> > : to insert between other things or parts : intercalate. 3 : to estimate
> > 
> > values of (data or a function) between two known values. intransitive
> > verb.
> > 
> > Interpolation - Wikipedia
> > en.wikipedia.org › wiki › Interpolation
> > In the mathematical field of numerical analysis, interpolation is a type
> > of estimation, a method of ... variable, may be contrary to commonsense,
> > i.e. to what is known about the experimental system which has generated
> > the data points.
> > 
> > ...
> > 
> > In computer graphics, interpolation is the creation of new values that
> > lie between known values. ... Another example is when a video image in a
> > low resolution is upscaled to display on a monitor with a higher
> > resolution, the missing lines are created by interpolation.
> > 
> > Definition of interpolation | PCMag
> > www.pcmag.com › Encyclopedia › I
> > ='
> > 
> > define interpolation computing
> > 
> > `=
> > What is interpolation in computer science?
> > In the context of live-action and computer animation, interpolation is
> > inbetweening, or filling in frames between the key frames. It typically
> > calculates the in-between frames through use of (usually) piecewise
> > polynomial interpolation to draw images semi-automatically.
> > 
> > ...
> > 
> > Interpolation (computer graphics) - Wikipedia
> > en.wikipedia.org › wiki › Interpolation_(computer_graph...
> > Search for: What is interpolation in computer science?
> > ='
> > 
> > Don't know (really) why I bothered to write this, maybe just to express
> > some frustration, or maybe by writing it I'll clear my brain slightly.  I
> > guess I could have written it and never sent it -- I'm occasionally that
> > disciplined, but not always ;-)

[toc] | [prev] | [next] | [standalone]


#227973 — Re: define (or translate, or substitute for) "interpolate": Re: rsync --delete

From<tomas@tuxteam.de>
Date2020-10-19 15:00 +0200
SubjectRe: define (or translate, or substitute for) "interpolate": Re: rsync --delete
Message-ID<B1CVz-3Yg-5@gated-at.bofh.it>
In reply to#227970

[Multipart message — attachments visible in raw view] — view raw

On Mon, Oct 19, 2020 at 08:29:32AM -0400, rhkramer@gmail.com wrote:

[...]

> Interpolation - Wikipedia
> en.wikipedia.org › wiki › Interpolation
> In the mathematical field of numerical analysis, interpolation is a type of 
> estimation, a method of ... variable, may be contrary to commonsense, i.e. to 
> what is known about the experimental system which has generated the data 
> points.

To be fair, you should quote wikipedia thoroughly. In the disambiguation
page [1] you do find the current use:

  String interpolation, in computing, the substitution of variables by their values

So that use is "out there". You better take note of it :-)

Cheers

[1] https://en.wikipedia.org/wiki/Interpolation_(disambiguation)

 - t

[toc] | [prev] | [next] | [standalone]


#227993 — Re: define (or translate, or substitute for) "interpolate": Re: rsync --delete

Fromrhkramer@gmail.com
Date2020-10-20 02:10 +0200
SubjectRe: define (or translate, or substitute for) "interpolate": Re: rsync --delete
Message-ID<B1NnY-22Y-11@gated-at.bofh.it>
In reply to#227973
Thanks!

On Monday, October 19, 2020 08:55:01 AM tomas@tuxteam.de wrote:
> To be fair, you should quote wikipedia thoroughly. In the disambiguation
> page [1] you do find the current use:
> 
>   String interpolation, in computing, the substitution of variables by
> their values

[toc] | [prev] | [next] | [standalone]


#228002 — Re: define (or translate, or substitute for) "interpolate": Re: rsync --delete

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2020-10-20 05:50 +0200
SubjectRe: define (or translate, or substitute for) "interpolate": Re: rsync --delete
Message-ID<B1QOR-40z-1@gated-at.bofh.it>
In reply to#227993
On Saturday, October 17, 2020 06:01:13 PM David Christensen wrote:
> I don't use Bourne arrays, and I barely understand how the shell 
> interpolates lists and preserves items containing whitespace.  When I
> can't figure it out, I switch to Perl.


On 2020-10-19 05:29, rhkramer@gmail.com wrote:
> I'm looking for an alternate thing to think of when I see the word 
> interpolate -- I guess maybe interpret or substitute would be good
> ways for me to think about it (think when I see the word interpolate)
> (maybe see rant, below).


On Monday, October 19, 2020 08:55:01 AM tomas@tuxteam.de wrote:
> To be fair, you should quote wikipedia thoroughly. In the 
> disambiguation page [1] you do find the current use:
> 
> String interpolation, in computing, the substitution of variables by
>  their values

"String interpolation" is what I meant.  Thank you for finding the 
reference.  :-)


David

[toc] | [prev] | [next] | [standalone]


#227968

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2020-10-19 14:10 +0200
Message-ID<B1C9c-3Hw-5@gated-at.bofh.it>
In reply to#227892
On Fri, Oct 16, 2020 at 05:09:42PM -0500, Mike McClain wrote:
> Params=(-a --inplace --delete);
> Flash=/sda/rpi4b
> cd /home/mike

You forgot to check the result of this cd.  This is critically important;
if the cd fails, you do NOT want the script to continue.

cd /home/mike || exit

> [ ! -d $Flash/mike ] && mkdir $Flash/mike;

You should quote correctly, as a good habit, even in the cases where
you're expanding a variable with known content.

Also, you don't need the separate is-a-directory check.  You can replace
this line with:

mkdir -p "$Flash/mike"

> echo /usr/bin/rsync $Params --exclude-from=/home/mike/.rsync_exclude . $Flash/mike

You correctly made Params an array variable, but you didn't expand it
correctly.  Also, you missed quotes in two places.

Finally, using an explicit /usr/bin/rsync is sketchy at best.  You
should already have /usr/bin in your PATH.

echo rsync "${Params[@]}" --exclude-from=/home/mike/.rsync_exclude . "$Flash/mike"

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.debian.user


csiph-web