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


Groups > linux.debian.user > #228023

Re: rsync --delete

From The Wanderer <wanderer@fastmail.fm>
Newsgroups linux.debian.user
Subject Re: rsync --delete
Date 2020-10-20 15:50 +0200
Message-ID <B20bv-1fk-1@gated-at.bofh.it> (permalink)
References (2 earlier) <B1BZw-3oQ-13@gated-at.bofh.it> <B1QlQ-3Rv-3@gated-at.bofh.it> <B1Yjn-7a-11@gated-at.bofh.it> <B1Zfs-GD-13@gated-at.bofh.it> <B1ZyN-12w-5@gated-at.bofh.it>
Organization This space intentionally left blank.

Show all headers | View raw


[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

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


Thread

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

csiph-web