Re: Shell function & variable usage.

2024-12-11 Thread Anssi Saari
pe...@easthope.ca writes: > In a realistic case, there are more than two exclusion patterns. > Comments or suggestions about the two possibilities? Astonishingly > better ideas? =8~o Put the exlucde patterns in a file and use --exclude-from=file? Works for me, so far with tar and bup, rsync h

Re: Shell function & variable usage.

2024-12-08 Thread peter
From: Greg Wooledge Date: Sat, 7 Dec 2024 11:08:54 -0500 > "${exclusions[@]//#/--exclude=}" In a shell script; correct? I'm making a shell function declared in .bashrc. Numerous syntactical variations were unsuccessful. Maybe a simple escape syntax is needed. Stretched a test out

Re: Shell function & variable usage.

2024-12-07 Thread Greg Wooledge
On Sat, Dec 07, 2024 at 06:19:20 -0700, pe...@easthope.ca wrote: > From: Greg Wooledge > Date: Fri, 6 Dec 2024 18:44:04 -0500 > > Store the exclusions in an ARRAY, not in a string. Then create a > > second array which contains the spelled-out --exclude=... options. > > Unfamiliar to me &

Re: Shell function & variable usage.

2024-12-07 Thread peter
From: Greg Wooledge Date: Fri, 6 Dec 2024 18:44:04 -0500 > Store the exclusions in an ARRAY, not in a string. Then create a > second array which contains the spelled-out --exclude=... options. Unfamiliar to me & interesting. What benefits outweigh the additional complexity? Thanks,

Re: Shell function & variable usage.

2024-12-07 Thread Karl Vogel
On Fri 06 Dec 2024 at 18:30:27 (-0500), pe...@easthope.ca wrote: > Hypothetical shell usages (1) & (2). > > (1) > Restore() { \ > source=somewhere/Backup/ ; > destination=elsewhere/workingDirectory ; > rsync \ > --exclude '*.mp3' \ > --exclude '*.mp4' \ > -anuv $source $destination ; }

Re: Shell function & variable usage.

2024-12-06 Thread eben
On 12/6/24 18:46, e...@gmx.us wrote: > overengineered Greg's solution is better.

Re: Shell function & variable usage.

2024-12-06 Thread Greg Wooledge
On Fri, Dec 06, 2024 at 18:46:06 -0500, e...@gmx.us wrote: > You could do something > overengineered like defining an array "excludepatterns" for patterns, and > then doing something like > > rsync \ > $(for pattern in ${excludepatterns[@]} ; do > echo -- "--exclude '$pattern'" > done) > > Mo

Re: Shell function & variable usage.

2024-12-06 Thread eben
On 12/6/24 17:11, pe...@easthope.ca wrote: These > rsync \ > --exclude '*.mp3' \ >--exclude '*.mp4' \ > rsync \ > --exclude=$exclusions are not the same. In the first one you have "--exclude" for each pattern, and in the second you have it once. I suspect the first one is correct,

Re: Shell function & variable usage.

2024-12-06 Thread Greg Wooledge
On Fri, Dec 06, 2024 at 15:11:51 -0700, pe...@easthope.ca wrote: > (2) > exclusions='*.mp3' > exclusions+='*.mp4' > Restore() { \ > source=somewhere/Backup/ ; > echo "source is $source." ; > destination=elsewhere/workingDirectory ; > echo "destination is $destination." ; > rsync \ > -an