Re: Shell function.

2025-05-16 Thread peter
From: Greg Wooledge Date: Fri, 16 May 2025 11:41:00 -0400 > Why are you setting the DISPLAY variable? # Cannot parse arguments: Cannot open display: wasn't usable. > ... at best, it's only viable in a very specialized setup. Correct. A specialized setup and I'm working on a better so

Re: Shell function.

2025-05-16 Thread peter
From: Greg Wooledge Date: Fri, 16 May 2025 11:41:00 -0400 > Why are you setting the DISPLAY variable? # Cannot parse arguments: Cannot open display: wasn't usable. > ... at best, it's only viable in a very specialized setup. Correct. A specialized setup and I'm working on a better so

Re: Re (2): Shell function.

2025-05-16 Thread tomas
On Fri, May 16, 2025 at 11:41:00AM -0400, Greg Wooledge wrote: > On Fri, May 16, 2025 at 08:05:50 -0700, pe...@easthope.ca wrote: > > Currently have this. > > ev () { /usr/bin/evince "$@" & } > > > > DISPLAY is set in .bashrc now. Not needed in trivial functions. > > Why are you setting the DISP

Re: Re (2): Shell function.

2025-05-16 Thread Greg Wooledge
On Fri, May 16, 2025 at 08:05:50 -0700, pe...@easthope.ca wrote: > Currently have this. > ev () { /usr/bin/evince "$@" & } > > DISPLAY is set in .bashrc now. Not needed in trivial functions. Why are you setting the DISPLAY variable? That sounds like a really bad idea. Or, at best, it's only vi

Re (2): Shell function.

2025-05-16 Thread peter
From: 🦓 Date: Thu, 15 May 2025 18:23:59 +0200 > you might wanna background it from your tty Currently have this. ev () { /usr/bin/evince "$@" & } DISPLAY is set in .bashrc now. Not needed in trivial functions. Thx,... p. -- VoIP: +1 604 670 0140 work: en.wikibooks.or

Re: Shell function.

2025-05-16 Thread peter
From: Will Mengarini Date: Thu, 15 May 2025 10:07:19 -0700 > ... evince can display multiple URLs ... Hadn't noticed that. Revised to this. ev () { /usr/bin/evince "$@" & } Thx, ... p. -- VoIP: +1 604 670 0140 work: en.wikibooks.org/wiki/User:PeterEasthope

Re: Shell function.

2025-05-16 Thread peter
From: Lee Date: Thu, 15 May 2025 13:02:27 -0400 > quoting $1 Revised to this. ev () { /usr/bin/evince "$@" & } Thx, ... p. -- VoIP: +1 604 670 0140 work: en.wikibooks.org/wiki/User:PeterEasthope

Re: Shell function.

2025-05-15 Thread Max Nikulin
On 15/05/2025 22:42, pe...@easthope.ca wrote: Given this function. You have not described use cases ev () { case $# in 0) /usr/bin/evince --display=:0 ;; 1) /usr/bin/evince --display=:0 $1 ;; *) echo "Too many arguments." ;; esac } Can improvements be suggested? Install shellcheck

Re: Shell function.

2025-05-15 Thread Eben King
On 5/15/25 11:42, pe...@easthope.ca wrote: Hi, Given this function. ev () { case $# in 0) /usr/bin/evince --display=:0 ;; 1) /usr/bin/evince --display=:0 $1 ;; *) echo "Too many arguments." ;; esac } Can improvements be suggested? When you refer to a variable you should wrap it i

Re: Shell function.

2025-05-15 Thread Will Mengarini
* pe...@easthope.ca [25-05/15=Th 08:42 -0700]: >> ev () { case $# in >> 0) /usr/bin/evince --display=:0 ;; >> 1) /usr/bin/evince --display=:0 $1 ;; >> *) echo "Too many arguments." ;; esac } >> Can improvements be suggested? * ? [25-05/15=Th 18:23 +0200]: > you can shorten ev to > ev(){ ev

Re: Shell function.

2025-05-15 Thread debian-user
pe...@easthope.ca wrote: > Hi, > > Given this function. > > ev () { case $# in > 0) /usr/bin/evince --display=:0 ;; > 1) /usr/bin/evince --display=:0 $1 ;; > *) echo "Too many arguments." ;; esac } > > Can improvements be suggested? "Too many arguments." doesn't seem quite right. If evinc

Re: Shell function.

2025-05-15 Thread Lee
On Thu, May 15, 2025 at 12:00 PM peter wrote: > > Hi, > > Given this function. > > ev () { case $# in > 0) /usr/bin/evince --display=:0 ;; > 1) /usr/bin/evince --display=:0 $1 ;; > *) echo "Too many arguments." ;; esac } > > Can improvements be suggested? quoting $1 I don't know about evinc

Re: Shell function.

2025-05-15 Thread 🦓
you can shorten ev to ev(){ evince -d ${DISPLAY=:0} ${1+"$@"};} you might wanna background it from your tty ev() { evince ${1+"$@"}&} unless you need to see the display errors or have an rm $pdf waiting to not fire prematurely Op do 15 mei 2025 om 18:00 schreef : > ev () { case $# in > 0) /

Shell function.

2025-05-15 Thread peter
Hi, Given this function. ev () { case $# in 0) /usr/bin/evince --display=:0 ;; 1) /usr/bin/evince --display=:0 $1 ;; *) echo "Too many arguments." ;; esac } Can improvements be suggested? Thx, ... P. -- VoIP: +1 604 670 0140 work: en.wikibooks.org/wiki/User:PeterEasthop

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.

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

Shell function & variable usage.

2024-12-06 Thread peter
Hypothetical shell usages (1) & (2). (1) Restore() { \ source=somewhere/Backup/ ; echo "source is $source." ; destination=elsewhere/workingDirectory ; echo "destination is $destination." ; rsync \ --exclude '*.mp3' \ --exclude '*.mp4' \ -anuv $source $destination ; } (2) exclusio

Re (2): Interactive definition of a shell function.

2013-09-12 Thread peasthope
From: Vincent Zweije Date: Thu, 12 Sep 2013 17:19:32 +0200 > The closing } is only recognized where a new command could have > started. Terminate your command with a semicolon. > > cpST () { cp Source Target; } Thanks, ... Peter E. -- 123456789 123456789 123456789 1234567

Interactive definition of a shell function.

2013-09-12 Thread peasthope
Suppose a user wants to make shell function such as this. cpST () { cp Source Target } The shell is waiting for a command so it can't be typed directly at the prompt. This also doesn't work. peter@dalton:~$ dash -c "cpST () { cp Source Target }" dash: 1: Synta

Re: Interactive definition of a shell function.

2013-09-12 Thread Vincent Zweije
On Thu, Sep 12, 2013 at 08:06:11AM -0700, peasth...@shaw.ca wrote: || Suppose a user wants to make shell function such as this. ||cpST () { cp Source Target } || The shell is waiting for a command so it can't be typed || directly at the prompt. Yes, it can. || This also doesn&#