Re: [DNG] [OT] bash / quote weirdness

2022-01-14 Thread Steve Litt
Simon said on Thu, 13 Jan 2022 18:38:56 + >Steve Litt wrote: > >> This is one reason why, in shellscripts, you >> need to quote almost all variables: So they act correctly with the >> space laden filenames that windows dwoobydogs just love to create. > >Not just Windows users. I regularly u

Re: [DNG] [OT] bash / quote weirdness

2022-01-14 Thread Steve Litt
Olaf Meeuwissen said on Fri, 14 Jan 2022 18:40:40 +0900 >Hi, > >Steve Litt writes: > >> [...] Here at Troubleshooters.Com, spaces and all punctuation except >> underscore and hyphen are forbidden, but files coming in from the >> outside have horrible filenames. > >Pretty sure you allow periods

Re: [DNG] [OT] bash / quote weirdness

2022-01-14 Thread Olaf Meeuwissen via Dng
Hi, Steve Litt writes: > [...] Here at Troubleshooters.Com, spaces and all punctuation except > underscore and hyphen are forbidden, but files coming in from the > outside have horrible filenames. Pretty sure you allow periods too ;-P -- Olaf MeeuwissenFSF Associate Member s

Re: [DNG] [OT] bash / quote weirdness

2022-01-14 Thread Alessandro Vesely via Dng
On Thu 13/Jan/2022 19:38:56 +0100 Simon wrote: Similarly with file names. Once upon a time the human had to adapt to what the computer supported - such as fitting your entire file name into 8 characters. Now the computer (mostly) supports what is natural for a human - and that includes using

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Hendrik Boom
On Thu, Jan 13, 2022 at 06:38:56PM +, Simon wrote: > Steve Litt wrote: > > > This is one reason why, in shellscripts, you > > need to quote almost all variables: So they act correctly with the > > space laden filenames that windows dwoobydogs just love to create. > > Not just Windows users.

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Simon
Steve Litt wrote: > This is one reason why, in shellscripts, you > need to quote almost all variables: So they act correctly with the > space laden filenames that windows dwoobydogs just love to create. Not just Windows users. I regularly use spaces in file names. There’s an argument that compu

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread william moss via Dng
On 1/13/22 09:43, Antony Stone wrote: On Thursday 13 January 2022 at 15:07:22, Hendrik Boom wrote: On Wed, Jan 12, 2022 at 05:45:08PM -0500, Steve Litt wrote: [slitt@mydesk ~]$ cat -n /etc/fstab | cut -b 1-20 | head -n5 1 UUID=730eaf92 2 UUID=41abb5fd 3 UUID=96cfdfb3

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Martial Bornet (gmail) via Dng
Hi everyone, to better understand how the shell interprets quotes, you should compile and use the following small C program to test some expressions : $ cat args.c #include    #include    int main(int argc, char *argv[]) {     int         _i;     printf("ARGC = %d\n", argc);     for (_i

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Antony Stone
On Thursday 13 January 2022 at 18:19:23, Benjamin Riefenstahl wrote: > Steve Litt writes: > > [slitt@mydesk ~]$ "cat -n" /etc/fstab | cut -b 1-20 | head -n5 > > bash: cat -n: command not found > > [slitt@mydesk ~]$ "cat -n /etc/fstab" | cut -b 1-20 | head -n5 > > bash: cat -n /etc/fstab: No such

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Gabe Stanton via Dng
No problem. Happy that you found it useful :D On Thu, 2022-01-13 at 10:52 -0500, Steve Litt wrote: > Thank you, thank you, THANK YOU!!! > > I've needed this for the last 23 years. Thank you! > > SteveT ___ Dng mailing list Dng@lists.dyne.org https:/

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Dr. Nikolaus Klepp via Dng
Anno domini 2022 Thu, 13 Jan 15:43:29 +0100 Antony Stone scripsit: > On Thursday 13 January 2022 at 15:07:22, Hendrik Boom wrote: > > > On Wed, Jan 12, 2022 at 05:45:08PM -0500, Steve Litt wrote: > > > > [slitt@mydesk ~]$ cat -n /etc/fstab | cut -b 1-20 | head -n5 > > > > > > 1UUID=730ea

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Steve Litt
Antony Stone said on Thu, 13 Jan 2022 15:43:29 +0100 >$ "cat fstab" >bash: cat fstab: command not found > >I have no idea what's really going on here. > > >Antony. Hi Anthony, Different programs handle commands with arguments different ways. sed -e handles the string that follows, which must be

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Steve Litt
Gabe Stanton via Dng said on Thu, 13 Jan 2022 07:03:57 -0700 >There's an html version and a pdf version of the abs guide available >here > >https://tldp.org/LDP/abs/html/ > >or here > >https://tldp.org/LDP/abs/abs-guide.pdf Thank you, thank you, THANK YOU!!! I've needed this for the last 23 year

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Antony Stone
On Thursday 13 January 2022 at 15:07:22, Hendrik Boom wrote: > On Wed, Jan 12, 2022 at 05:45:08PM -0500, Steve Litt wrote: > > [slitt@mydesk ~]$ cat -n /etc/fstab | cut -b 1-20 | head -n5 > > > > 1 UUID=730eaf92 > > 2 UUID=41abb5fd > > 3 UUID=96cfdfb3 > > 4

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Hendrik Boom
On Wed, Jan 12, 2022 at 05:45:08PM -0500, Steve Litt wrote: > > On the other hand... > > === > [slitt@mydesk ~]$ cat -n /etc/fstab | cut -b 1-20 | head -n5 > 1UUID=730eaf92 > 2UUID=41abb5fd > 3UUID=96cfdfb3 > 4

Re: [DNG] [OT] bash / quote weirdness

2022-01-13 Thread Gabe Stanton via Dng
I don't have anything of my own to add except that single quotes result in the same behavior as double quotes in this case. I was curious about that after reading about the difference between single and double quotes in the Advanced Bash Scripting Guide or abs guide. I'm a novice obviously. I wan

Re: [DNG] [OT] bash / quote weirdness

2022-01-12 Thread Steve Litt
Alessandro Vesely via Dng said on Wed, 12 Jan 2022 10:39:07 +0100 >On Wed 12/Jan/2022 01:27:45 +0100 Florian Zieboll via Dng wrote: >> On Tue, 11 Jan 2022 18:52:10 -0500 >> william moss wrote: >> >>> Bash is taking the string in the double quotes as a single command; >>> this is well documente

Re: [DNG] [OT] bash / quote weirdness

2022-01-12 Thread william moss via Dng
On 1/12/22 04:39, Alessandro Vesely via Dng wrote: On Wed 12/Jan/2022 01:27:45 +0100 Florian Zieboll via Dng wrote: On Tue, 11 Jan 2022 18:52:10 -0500 william moss wrote: Bash is taking the string in the double quotes as a single command; this is well documented. If either the command or para

Re: [DNG] [OT] bash / quote weirdness

2022-01-12 Thread Florian Zieboll via Dng
On Wed, 12 Jan 2022 10:39:07 +0100 Alessandro Vesely via Dng wrote: > On Wed 12/Jan/2022 01:27:45 +0100 Florian Zieboll via Dng wrote: > > > > I am replying to the list to share the valid (tested) alternative. > > Thanks a lot! > > > Bash still considers a quoted command as such, for example

Re: [DNG] [OT] bash / quote weirdness

2022-01-12 Thread Alessandro Vesely via Dng
On Wed 12/Jan/2022 01:27:45 +0100 Florian Zieboll via Dng wrote: On Tue, 11 Jan 2022 18:52:10 -0500 william moss wrote: Bash is taking the string in the double quotes as a single command; this is well documented. If either the command or parameters have spaces, you will have to use eval. Check

Re: [DNG] [OT] bash / quote weirdness

2022-01-11 Thread Florian Zieboll via Dng
On Wed, 12 Jan 2022 01:10:11 +0100 Antony Stone wrote: > Double-quoting turns the string into a single token, and therefore > the parser sees the line as: > > token 1 = "unrar x" > token 2 = "$f" > > Without the double quoting, it's: > > token 1 = "unrar" > token 2 = "x

Re: [DNG] [OT] bash / quote weirdness

2022-01-11 Thread Florian Zieboll via Dng
On Tue, 11 Jan 2022 18:52:10 -0500 william moss wrote: > Bash is taking the string in the double quotes as a single command; > this is well documented. If either the command or parameters have > spaces, you will have to use eval. Check the bash man page for > details. > > This will also usually

Re: [DNG] [OT] bash / quote weirdness

2022-01-11 Thread Florian Zieboll via Dng
On Tue, 11 Jan 2022 18:16:15 -0500 tempforever wrote: > I believe quoting $xcmd would instruct the shell to look for and > execute "unrar x" so unless you have an executable file named unrar\ > x within $PATH, it will fail.  The same thing happens within a shell: > ~$ "unrar x" > bash: unrar x: c

Re: [DNG] [OT] bash / quote weirdness

2022-01-11 Thread Antony Stone
On Wednesday 12 January 2022 at 00:08:38, Florian Zieboll via Dng wrote: > #!/bin/bash > for f in "$@" ; do > xcmd="unrar x" > $xcmd "$f" > done > > Can please somebody explain, why, if I double-quote the "$xcmd" > variable in line 4, the script fails with > > ./test.sh: line 4: un

Re: [DNG] [OT] bash / quote weirdness

2022-01-11 Thread tempforever
Florian Zieboll via Dng wrote: > Dear list, > > this im my 'test.sh': > > #!/bin/bash > for f in "$@" ; do > xcmd="unrar x" > $xcmd "$f" > done > > Can please somebody explain, why, if I double-quote the "$xcmd" > variable in line 4, the script fails with > > ./test.sh: line 4: unrar

[DNG] [OT] bash / quote weirdness

2022-01-11 Thread Florian Zieboll via Dng
Dear list, this im my 'test.sh': #!/bin/bash for f in "$@" ; do xcmd="unrar x" $xcmd "$f" done Can please somebody explain, why, if I double-quote the "$xcmd" variable in line 4, the script fails with ./test.sh: line 4: unrar x: command not found ??? Commands without paramete