Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Only the hypocrite is really rotten to the core." -- Hannah Arendt.


devel / comp.unix.shell / Re: spaces in file names

SubjectAuthor
* spaces in file namesPopping Mad
+- Re: spaces in file namesMartin Τrautmann
+* Re: spaces in file namesJanis Papanagnou
|+* Re: spaces in file namesJanis Papanagnou
||`* Re: spaces in file namesPopping Mad
|| `* Re: spaces in file namesJanis Papanagnou
||  `* Re: spaces in file namesKenny McCormack
||   `- Re: spaces in file namesJanis Papanagnou
|`* Re: spaces in file namesPopping Mad
| +* Re: spaces in file namesWilliam Unruh
| |`- Re: spaces in file namesPopping Mad
| +* Re: spaces in file namesKaz Kylheku
| |+* Re: spaces in file namesKeith Thompson
| ||`- Re: spaces in file namesJanis Papanagnou
| |`* Re: spaces in file namesPopping Mad
| | +* Re: spaces in file namesWilliam Unruh
| | |`* Re: spaces in file namesPopping Mad
| | | `* Re: spaces in file namesJanis Papanagnou
| | |  `- Re: spaces in file namesEric Pozharski
| | `* Re: spaces in file namesJanis Papanagnou
| |  `- Re: spaces in file namesPopping Mad
| `* Re: spaces in file namesJanis Papanagnou
|  `* Re: spaces in file namesKenny McCormack
|   `- Re: spaces in file namesJanis Papanagnou
+* Re: spaces in file namesEd Morton
|`- Re: spaces in file namesPopping Mad
+* Re: spaces in file namesBen Bacarisse
|+* Re: spaces in file namesPopping Mad
||`- Re: spaces in file namesJanis Papanagnou
|`* Re: spaces in file namesPopping Mad
| `* Re: spaces in file namesJanis Papanagnou
|  +* Re: spaces in file namesBen Bacarisse
|  |`* Re: spaces in file namesJanis Papanagnou
|  | `- Re: spaces in file namesBen Bacarisse
|  `* Re: spaces in file namesKenny McCormack
|   `- Re: spaces in file namesJanis Papanagnou
+* Re: spaces in file namesHelmut Waitzmann
|+* Re: spaces in file namesKaz Kylheku
||+- Re: spaces in file namesJanis Papanagnou
||`- Re: spaces in file namesHelmut Waitzmann
|+* Re: spaces in file namesPopping Mad
||`- Re: spaces in file namesJanis Papanagnou
|`* Re: spaces in file namesPopping Mad
| `- Why 'for v in `ls ...` ; do ... ; done' won't work: command substitution and fieHelmut Waitzmann
`* Re: spaces in file namesRandal L. Schwartz
 +- Re: spaces in file namesKeith Thompson
 `* Re: spaces in file namesBarry Margolin
  +- Re: spaces in file namesEli the Bearded
  +- Re: spaces in file namesJosef Moellers
  `- Re: spaces in file namesBenjamin Esham

Pages:12
spaces in file names

<samjbi$q3a$1@reader1.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3971&group=comp.unix.shell#3971

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!not-for-mail
From: rain...@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: spaces in file names
Date: Sun, 20 Jun 2021 01:21:38 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Lines: 33
Message-ID: <samjbi$q3a$1@reader1.panix.com>
NNTP-Posting-Host: www3.mrbrklyn.com
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: reader1.panix.com 1624166578 26730 96.57.23.83 (20 Jun 2021 05:22:58 GMT)
X-Complaints-To: abuse@panix.com
NNTP-Posting-Date: Sun, 20 Jun 2021 05:22:58 +0000 (UTC)
X-Mozilla-News-Host: news://news.panix.com:119
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
Content-Language: en-US
 by: Popping Mad - Sun, 20 Jun 2021 05:21 UTC

I found this snippet on the web

#!/bin/bash

for a in ./*.flac; do
< /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"
done

I wanted to do more like

for a in `ls ./*.flac`; do
ffmeg - "$a" "$a".mp3
done

but it broke with each space for song names
"I Had A Dream"

I
Had
A Dream

which is not what I wanted. Can I get around this?

I also do not understand this

"${a[@]/%flac/mp3}"

Re: spaces in file names

<slrnscu0o2.11m3.t-usenet@ID-685.user.individual.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3973&group=comp.unix.shell#3973

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: t-use...@gmx.net (Martin Τrautmann)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 10:57:38 +0200
Organization: slrn user
Lines: 7
Message-ID: <slrnscu0o2.11m3.t-usenet@ID-685.user.individual.de>
References: <samjbi$q3a$1@reader1.panix.com>
Reply-To: traut@gmx.de
Injection-Info: reader02.eternal-september.org; posting-host="bf5346df862bfa1110c1a7a1bde9a2eb";
logging-data="16945"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19brk4RI2wPZ2G6BVvZ56ve"
User-Agent: slrn/1.0.3 (Darwin)
Cancel-Lock: sha1:QAnKg4/v/lEw+cLUMhs3NSDiJOY=
X-No-Archive: Yes
 by: Martin Τrautmann - Sun, 20 Jun 2021 08:57 UTC

On Sun, 20 Jun 2021 01:21:38 -0400, Popping Mad wrote:
> but it broke with each space for song names
> "I Had A Dream"

put it within "" or ''

or replace " " by "\ "

Re: spaces in file names

<san3rs$mri$1@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3974&group=comp.unix.shell#3974

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 12:04:44 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 75
Message-ID: <san3rs$mri$1@news-1.m-online.net>
References: <samjbi$q3a$1@reader1.panix.com>
NNTP-Posting-Host: 2001:a61:252a:da01:b99e:d49c:d820:ca3e
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1624183484 23410 2001:a61:252a:da01:b99e:d49c:d820:ca3e (20 Jun 2021 10:04:44 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Sun, 20 Jun 2021 10:04:44 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Enigmail-Draft-Status: N1110
In-Reply-To: <samjbi$q3a$1@reader1.panix.com>
 by: Janis Papanagnou - Sun, 20 Jun 2021 10:04 UTC

On 20.06.2021 07:21, Popping Mad wrote:
> I found this snippet on the web
>
> #!/bin/bash
>
> for a in ./*.flac; do
> < /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"
> done
>
>
> I wanted to do more like

Amazing!

It's beyond me why folks dismiss a correct and efficient
construct (a simple for-loop file pattern) and want to
replace it by wrong and inefficient constructs (subshell
and ls) - ...and then wonder why the code breaks!

So the first part of the answer is; use (as in the original
code)

for a in ./*.flac; do

>
> for a in `ls ./*.flac`; do
> ffmeg - "$a" "$a".mp3
> done
>
> but it broke with each space for song names
> "I Had A Dream"
>
>
> I
> Had
> A
> Dream
>
> which is not what I wanted. Can I get around this?
>
>
> I also do not understand this
>
>
> "${a[@]/%flac/mp3}"
>

I don't know about bash (inspect the man page!) but I suppose it
is that same as in Kornshell where it is:

${parameter/%pattern/string}

Expands parameter and replaces the longest match of pattern
with the given string. [anchored at the end of the string]

where ${a[@]} is an array variable where the substitution occurs
on each element. (This is a non-standard construct and can be
replaced by a standard one (see below).)

So it replaces a flac file extension by mp3.

What I don't understand is why a[@] (an array) is used since
you iterate over the array elements "$a" .

What you probably just want is basically

for a in ./*.flac
do
ffmeg ... "$a" ... "${a%flac}.mp3"
done

(add your other ffmpeg options as needed).

Janis

Re: spaces in file names

<san8k2$o5p$2@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3975&group=comp.unix.shell#3975

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 13:25:54 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 19
Message-ID: <san8k2$o5p$2@news-1.m-online.net>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net>
NNTP-Posting-Host: 2001:a61:252a:da01:b99e:d49c:d820:ca3e
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1624188354 24761 2001:a61:252a:da01:b99e:d49c:d820:ca3e (20 Jun 2021 11:25:54 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Sun, 20 Jun 2021 11:25:54 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
In-Reply-To: <san3rs$mri$1@news-1.m-online.net>
 by: Janis Papanagnou - Sun, 20 Jun 2021 11:25 UTC

Oops..

On 20.06.2021 12:04, Janis Papanagnou wrote:
>
> What you probably just want is basically
>
> for a in ./*.flac
> do
> ffmeg ... "$a" ... "${a%flac}.mp3"

ffmeg ... "$a" ... "${a%.flac}.mp3"

> done
>
> (add your other ffmpeg options as needed).
>
> Janis
>

Re: spaces in file names

<sanhvo$7p6$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3976&group=comp.unix.shell#3976

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 09:05:44 -0500
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <sanhvo$7p6$1@dont-email.me>
References: <samjbi$q3a$1@reader1.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 20 Jun 2021 14:05:44 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5e653a600d673f34942abe12a946972f";
logging-data="7974"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/G3OPk822f6h82el9qbZZ"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:Qx+yK4433+Gc1dFgtThVaYNuGko=
In-Reply-To: <samjbi$q3a$1@reader1.panix.com>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 210619-6, 06/19/2021), Outbound message
 by: Ed Morton - Sun, 20 Jun 2021 14:05 UTC

On 6/20/2021 12:21 AM, Popping Mad wrote:
> I found this snippet on the web
>
> #!/bin/bash
>
> for a in ./*.flac; do
> < /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"
> done
>
>
> I wanted to do more like
>
>
> for a in `ls ./*.flac`; do
> ffmeg - "$a" "$a".mp3
> done
>
> but it broke with each space for song names

Some shell programming fundamentals:

https://mywiki.wooledge.org/DontReadLinesWithFor
https://mywiki.wooledge.org/BashFAQ/001
https://mywiki.wooledge.org/ParsingLs

Ed.

Re: spaces in file names

<87y2b4bog0.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3977&group=comp.unix.shell#3977

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 15:28:15 +0100
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <87y2b4bog0.fsf@bsb.me.uk>
References: <samjbi$q3a$1@reader1.panix.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="b522524b6c9e6f7a013ed3c69677708f";
logging-data="29437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kVI2acA80Bwk3v+JWXU6prjV4A9Nf/Sk="
Cancel-Lock: sha1:s6r/71oCEtnE5Pre+DskG6pCQ6o=
sha1:zG359ELhi+WNxATqSrB78AO665M=
X-BSB-Auth: 1.a16565143f68618827ee.20210620152815BST.87y2b4bog0.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 20 Jun 2021 14:28 UTC

Popping Mad <rainbow@colition.gov> writes:

> I found this snippet on the web
>
> #!/bin/bash
>
> for a in ./*.flac; do
> < /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"
> done
>
>
> I wanted to do more like
>
>
> for a in `ls ./*.flac`; do
> ffmeg - "$a" "$a".mp3
> done
>
> but it broke with each space for song names
> "I Had A Dream"

The list that results from the ls command is subject to word splitting.

> Can I get around this?

That's been explained -- don't use ls! But if you have to use the
result of some command that gives the required strings line by line
(possibly containing spaces), you can use this pattern:

ls *.flac | while read a; do command_that_processes "$a"; done

> I also do not understand this
>
> "${a[@]/%flac/mp3}"

For some reason the author is treating a as an array. This is harmless,
but unless I'm missing something, it's also pointless. You could write

"${a/%flac/mp3}"

instead. The ${var/s1/s2} syntax gives the value of $var but with the
first occurrence of s1 replaced by s2. In the % form (${var/%s1/s2}) s1
must match as the end of $var.

--
Ben.

Re: spaces in file names

<8335tc4fz1.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3978&group=comp.unix.shell#3978

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!HfIKhyloB4UHAuWUgdVqHw.user.gioia.aioe.org.POSTED!not-for-mail
From: nn.throt...@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 19:13:06 +0200
Organization: Aioe.org NNTP Server
Lines: 63
Message-ID: <8335tc4fz1.fsf@helmutwaitzmann.news.arcor.de>
References: <samjbi$q3a$1@reader1.panix.com>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
NNTP-Posting-Host: HfIKhyloB4UHAuWUgdVqHw.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Complaints-To: abuse@aioe.org
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Cancel-Lock: sha1:ZmFjNtYJBA6b/r3s1WPykT9N2ME=
Mail-Copies-To: nobody
X-Notice: Filtered by postfilter v. 0.9.2
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
 by: Helmut Waitzmann - Sun, 20 Jun 2021 17:13 UTC

Popping Mad <rainbow@colition.gov>:
>I found this snippet on the web
>
>
>#!/bin/bash
>
>for a in ./*.flac; do
> < /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"
>done
>
>
>I wanted to do more like
>
>
>for a in `ls ./*.flac`; do
>ffmeg - "$a" "$a".mp3
>done

Why not just do “for a in ./*.flac; do”?

>but it broke with each space for song names
>

Yes.  That is field splitting.  See
<https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05>
for an explanation.

for a in `ls ./*.flac`; do

will not work (because of field splitting), neither will

for a in "`ls ./*.flac`"; do

do.  Certainly, in the second form, there is no field splitting
because of the double quotes.  But because “ls” doesn't put any
unambiguous fences between one filename and the other into its
output, the shell will not be able to tell the end of one filename
and the beginning of the next.  => All output from “ls” will be
assigned as one word to the variable “a”, which is not what you
want, either.

>Can I get around this?
>

Yes.  Just let the shell rather than “ls” collect the filenames:

for a in ./*.flac
do
if ! test -e "$a" && ! test -L "$a"
then
continue
fi
ffmeg - "$a" "$a".mp3
done

Re: spaces in file names

<20210620104303.86@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3979&group=comp.unix.shell#3979

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 17:46:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <20210620104303.86@kylheku.com>
References: <samjbi$q3a$1@reader1.panix.com>
<8335tc4fz1.fsf@helmutwaitzmann.news.arcor.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 20 Jun 2021 17:46:27 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5931accd828974a0bbd394b6c8a0383e";
logging-data="32578"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PUnZviL6O9cy5X4sMHxeRRx1CdQPmZAM="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:1863rmmA7baFct+VkIRniRJmIm0=
 by: Kaz Kylheku - Sun, 20 Jun 2021 17:46 UTC

On 2021-06-20, Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
> Popping Mad <rainbow@colition.gov>:
>>I found this snippet on the web
>>
>>
>>#!/bin/bash
>>
>>for a in ./*.flac; do
>> < /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"
>>done
>>
>>
>>I wanted to do more like
>>
>>
>>for a in `ls ./*.flac`; do
>>ffmeg - "$a" "$a".mp3
>>done
>
> Why not just do “for a in ./*.flac; do”?

One reason might be that it breaks on the case when there is no match,
stupidly producing the pattern syntax itself as the expansion.

Whereas $(ls pattern), though complaining with a diagnostic on stderr,
will correctly produce an empty expansion rather than pattern.

This is why ls sometimes gets used instead of just globbing even by
people who know what they are doing.

ls will receive the unexpanded non-matching pattern as an argument, and
then consume it.

Re: spaces in file names

<sao44a$vsa$1@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3980&group=comp.unix.shell#3980

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 21:15:22 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 18
Message-ID: <sao44a$vsa$1@news-1.m-online.net>
References: <samjbi$q3a$1@reader1.panix.com>
<8335tc4fz1.fsf@helmutwaitzmann.news.arcor.de>
<20210620104303.86@kylheku.com>
NNTP-Posting-Host: 2001:a61:252a:da01:4830:f8e9:ebbb:6e07
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: news-1.m-online.net 1624216522 32650 2001:a61:252a:da01:4830:f8e9:ebbb:6e07 (20 Jun 2021 19:15:22 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Sun, 20 Jun 2021 19:15:22 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
In-Reply-To: <20210620104303.86@kylheku.com>
 by: Janis Papanagnou - Sun, 20 Jun 2021 19:15 UTC

On 20.06.2021 19:46, Kaz Kylheku wrote:
> On 2021-06-20, Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
>> Popping Mad <rainbow@colition.gov>:
>>> #!/bin/bash
>>
>> Why not just do “for a in ./*.flac; do”?
>
> One reason might be that it breaks on the case when there is no match,
> stupidly producing the pattern syntax itself as the expansion.

In bash - seen used by the OP - that can at least be addressed by

shopt -s nullglob

(It would make sense to standardize some function like that.)

Janis

Re: spaces in file names

<83k0mo2os0.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3981&group=comp.unix.shell#3981

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!HfIKhyloB4UHAuWUgdVqHw.user.gioia.aioe.org.POSTED!not-for-mail
From: nn.throt...@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 23:45:51 +0200
Organization: Aioe.org NNTP Server
Lines: 49
Message-ID: <83k0mo2os0.fsf@helmutwaitzmann.news.arcor.de>
References: <samjbi$q3a$1@reader1.panix.com>
<8335tc4fz1.fsf@helmutwaitzmann.news.arcor.de>
<20210620104303.86@kylheku.com>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
NNTP-Posting-Host: HfIKhyloB4UHAuWUgdVqHw.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Complaints-To: abuse@aioe.org
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
X-Notice: Filtered by postfilter v. 0.9.2
Mail-Copies-To: nobody
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Cancel-Lock: sha1:ULhbllzDZgor1gpbd9upC3tsuWc=
 by: Helmut Waitzmann - Sun, 20 Jun 2021 21:45 UTC

Kaz Kylheku <563-365-8930@kylheku.com>:
>On 2021-06-20, Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
>> Popping Mad <rainbow@colition.gov>:

>>>I wanted to do more like
>>>
>>>
>>>for a in `ls ./*.flac`; do
>>>ffmeg - "$a" "$a".mp3
>>>done
>>
>> Why not just do “for a in ./*.flac; do”?
>>
>
>One reason might be that it breaks on the case when there is no
>match, stupidly producing the pattern syntax itself as the
>expansion.

Yes.  That's why I did

if ! test -e "$a" && ! test -L "$a"
then
continue
fi

in the body of the loop.

>Whereas $(ls pattern), though complaining with a diagnostic on stderr,
>will correctly produce an empty expansion rather than pattern.
>
>This is why ls sometimes gets used instead of just globbing even by
>people who know what they are doing.
>
>ls will receive the unexpanded non-matching pattern as an argument, and
>then consume it.

The tests for inode existence above will do the same.  But I agree
with Janis:  I'd like

shopt -s nullglob

or

set -o nullglob

to become part of the standard.

Re: spaces in file names

<86pmwguqr4.fsf@red.stonehenge.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3982&group=comp.unix.shell#3982

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx38.iad.POSTED!not-for-mail
From: mer...@stonehenge.com (Randal L. Schwartz)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
References: <samjbi$q3a$1@reader1.panix.com>
x-mayan-date: Long count = 13.0.8.11.3; tzolkin = 13 Akbal; haab = 1 Tzec
Message-ID: <86pmwguqr4.fsf@red.stonehenge.com>
Organization: Stonehenge Consulting Services; Portland, Oregon, USA
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (berkeley-unix)
Cancel-Lock: sha1:3kT5JagIDuq3TPcZEgN9EFdzOvM=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 12
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Sun, 20 Jun 2021 22:23:06 UTC
Date: Sun, 20 Jun 2021 15:15:43 -0700
X-Received-Bytes: 1379
 by: Randal L. Schwartz - Sun, 20 Jun 2021 22:15 UTC

You think spaces in filenames are weird? I often made a habit of making
a directory named \n (well, a literal newline) to test my shell scripts.
I figured if they could deal with a newline, they could probably deal
with most other things. Also to freak out people peeking at my
$HOME. :)

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Dart/Flutter consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig

Re: spaces in file names

<877dioxfsm.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3983&group=comp.unix.shell#3983

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sun, 20 Jun 2021 16:44:09 -0700
Organization: None to speak of
Lines: 13
Message-ID: <877dioxfsm.fsf@nosuchdomain.example.com>
References: <samjbi$q3a$1@reader1.panix.com>
<86pmwguqr4.fsf@red.stonehenge.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="aae4390ad199a33e8d6cd843e630f516";
logging-data="7875"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/x5PYSYKy/V1vYh3TF6ufO"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:cTAtq9+fzpTFXuY58s4kN42agNQ=
sha1:Xk7ZgX9s6l+IZep/mhuvwjJ+7M8=
 by: Keith Thompson - Sun, 20 Jun 2021 23:44 UTC

merlyn@stonehenge.com (Randal L. Schwartz) writes:
> You think spaces in filenames are weird? I often made a habit of making
> a directory named \n (well, a literal newline) to test my shell scripts.
> I figured if they could deal with a newline, they could probably deal
> with most other things. Also to freak out people peeking at my
> $HOME. :)

\n (a backslash followed by n) could also be an interesting test.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

Re: spaces in file names

<satthq$6kj$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3984&group=comp.unix.shell#3984

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www3.mrbrklyn.com!not-for-mail
From: rain...@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Tue, 22 Jun 2021 19:58:34 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <satthq$6kj$1@reader2.panix.com>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 22 Jun 2021 23:59:54 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www3.mrbrklyn.com:96.57.23.83";
logging-data="6803"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
In-Reply-To: <san3rs$mri$1@news-1.m-online.net>
Content-Language: en-US
Lines: 21
 by: Popping Mad - Tue, 22 Jun 2021 23:58 UTC

On 6/20/21 6:04 AM, Janis Papanagnou wrote:
> It's beyond me why folks dismiss a correct and efficient
> construct (a simple for-loop file pattern) and want to
> replace it by wrong and inefficient constructs (subshell
> and ls) - ...and then wonder why the code breaks!

well, because it is incoherent. A random ./* in the middle of a shell
statement with out an instruction like ls is naked.

flatbush:[ruben]:~$ ./*
bash: ./abr2.mp4: Permission denied

Aside from that the output is lines, and you don't expect it to break up
into words suddenly.

So there is nothing to be amazed at. It is simple language syntax,
nouns and verbs, that one would expect.

Why it breaks the script is my puzzle.

Re: spaces in file names

<sau05r$njm$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3985&group=comp.unix.shell#3985

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: unr...@invalid.ca (William Unruh)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Wed, 23 Jun 2021 00:44:43 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <sau05r$njm$1@dont-email.me>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net> <satthq$6kj$1@reader2.panix.com>
Injection-Date: Wed, 23 Jun 2021 00:44:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="38faaba3832270f6d65d853b967a5f25";
logging-data="24182"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19V82YaF5wKw2lXFsLb8z3G"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:CKiyQ3TdoQGE+AoWnxy0n5NCUdg=
 by: William Unruh - Wed, 23 Jun 2021 00:44 UTC

On 2021-06-22, Popping Mad <rainbow@colition.gov> wrote:
> On 6/20/21 6:04 AM, Janis Papanagnou wrote:
>> It's beyond me why folks dismiss a correct and efficient
>> construct (a simple for-loop file pattern) and want to
>> replace it by wrong and inefficient constructs (subshell
>> and ls) - ...and then wonder why the code breaks!
>
>
> well, because it is incoherent. A random ./* in the middle of a shell
> statement with out an instruction like ls is naked.

No idea what you are talking about

for i in ./*
do
....
done

Eg,
for i in ./*
do
echo "$i"
done

..
..
../StJohnsReservation (1).doc
..
..

>
> flatbush:[ruben]:~$ ./*
> bash: ./abr2.mp4: Permission denied

You really do not to read what people say.

>
> Aside from that the output is lines, and you don't expect it to break up
> into words suddenly.
>
> So there is nothing to be amazed at. It is simple language syntax,
> nouns and verbs, that one would expect.
>
>
> Why it breaks the script is my puzzle.

Re: spaces in file names

<20210622174241.378@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3986&group=comp.unix.shell#3986

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Wed, 23 Jun 2021 00:46:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <20210622174241.378@kylheku.com>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net> <satthq$6kj$1@reader2.panix.com>
Injection-Date: Wed, 23 Jun 2021 00:46:07 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8e5f7e6c44d87bc3a55481d33d87a7c0";
logging-data="25231"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2SON+iNdoJVbucvPftyaPRN0pT8imI3o="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:9MosVS4iTBj4ZSOXMhFc/J9BCaM=
 by: Kaz Kylheku - Wed, 23 Jun 2021 00:46 UTC

On 2021-06-22, Popping Mad <rainbow@colition.gov> wrote:
> On 6/20/21 6:04 AM, Janis Papanagnou wrote:
>> It's beyond me why folks dismiss a correct and efficient
>> construct (a simple for-loop file pattern) and want to
>> replace it by wrong and inefficient constructs (subshell
>> and ls) - ...and then wonder why the code breaks!
>
>
> well, because it is incoherent. A random ./* in the middle of a shell
> statement with out an instruction like ls is naked.

There is a bleeping instruction: "for x in"!

for x in ./* ; do ...

> flatbush:[ruben]:~$ ./*
> bash: ./abr2.mp4: Permission denied

Strawman nonsense. Nick checks out?

> So there is nothing to be amazed at. It is simple language syntax,
> nouns and verbs, that one would expect.

Yeah, simple language.

Nouns ... verbs ... nested backticks with an embedded useless ls ...

You know, natural!

Re: spaces in file names

<87y2b1w8rh.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3987&group=comp.unix.shell#3987

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Tue, 22 Jun 2021 20:38:10 -0700
Organization: None to speak of
Lines: 20
Message-ID: <87y2b1w8rh.fsf@nosuchdomain.example.com>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net> <satthq$6kj$1@reader2.panix.com>
<20210622174241.378@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="28e7cfb7a9d1bfdd32dfeb115dacde84";
logging-data="13028"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+K5Vcn8mVdp7VBsW2xThx1"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:AGpTljOXWx+SokSt15xDDvDv+rM=
sha1:KpPTOkOUssDozRf54psOcEQvQ0U=
 by: Keith Thompson - Wed, 23 Jun 2021 03:38 UTC

Kaz Kylheku <563-365-8930@kylheku.com> writes:
[...]
> for x in ./* ; do ...
[...]

I realize people are quoting articles from upthread, but is there any
particular reason to write
for x in ./* ; do ...
rather than
for x in * ; do ...
?

I know it matters in some contexts (for example, "echo *" if the first
file in the current directory is named "-n"), but it shouldn't matter
here as far as I can tell.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

Re: spaces in file names

<sav5mt$ql$1@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3988&group=comp.unix.shell#3988

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Wed, 23 Jun 2021 13:25:17 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 77
Message-ID: <sav5mt$ql$1@news-1.m-online.net>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net> <satthq$6kj$1@reader2.panix.com>
NNTP-Posting-Host: 2001:a61:252a:da01:7c7d:59b9:1662:62f2
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1624447517 853 2001:a61:252a:da01:7c7d:59b9:1662:62f2 (23 Jun 2021 11:25:17 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Wed, 23 Jun 2021 11:25:17 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Enigmail-Draft-Status: N1110
In-Reply-To: <satthq$6kj$1@reader2.panix.com>
 by: Janis Papanagnou - Wed, 23 Jun 2021 11:25 UTC

On 23.06.2021 01:58, Popping Mad wrote:
> On 6/20/21 6:04 AM, Janis Papanagnou wrote:
>> It's beyond me why folks dismiss a correct and efficient
>> construct (a simple for-loop file pattern) and want to
>> replace it by wrong and inefficient constructs (subshell
>> and ls) - ...and then wonder why the code breaks!
>
>
> well, because it is incoherent.

In which mental universe?

> A random ./* in the middle of a shell
> statement with out an instruction like ls is naked.

I think it makes no sense to discuss your mental picture of a
"naked construct or shell statement" (or whatever). It makes
more sense to understand shell syntax and semantics; that is
something you have to start.

Deviating from an existing (working) construct is the problem;
a problem that you introduced.

>
> flatbush:[ruben]:~$ ./*
> bash: ./abr2.mp4: Permission denied

So what? - The pattern expands by file globbing and gets a list
of matches. Since there is neither a shell construct (like 'for'
loop) nor a command (like 'echo') the first expanded word will
be treated as command. (If the first expanded word would be a
command, incidentally, that would even run. - Just to be sure;
I tell you that just for understanding the matter, not that you
should call the programs that way.)

Any globbing pattern will expand (if globbing is activated as it
is per default). You can put such patterns in any context where
it makes sense. (For example in a 'for'-loop, as argument to an
'echo' (or other) command, etc.)

>
> Aside from that the output is lines, and you don't expect it to break up
> into words suddenly.

Are you talking about the output of 'ls' or what? - Anyway you
don't see the output of ls if you put other constructs around
where (likely already mentioned) "word-splitting" happens.

Nothing here happens "suddenly". You transformed the code without
knowing what happens, and it just works as that specific shell
syntax is supposed to work.

>
> So there is nothing to be amazed at. It is simple language syntax,
> nouns and verbs, that one would expect.

Here are some more nouns and verbs: You fill water into a bottle,
turn the bottle horizontally, and are wondering why the water is
now leaving the bottle. - There is something like gravity! - In
shell it's syntax and operational semantics that rule how scripts
behave.

What is amazing is that you turned the bottle and expect the same
result that the water still stays within.

>
>
> Why it breaks the script is my puzzle.

Try understanding the operational semantics of "word splitting" in
the given context.

Try understanding how file globbing (expansion of file names given
shell patterns) works.

Janis

Re: spaces in file names

<sav636$vr$1@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3989&group=comp.unix.shell#3989

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Wed, 23 Jun 2021 13:31:50 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 28
Message-ID: <sav636$vr$1@news-1.m-online.net>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net> <satthq$6kj$1@reader2.panix.com>
<20210622174241.378@kylheku.com> <87y2b1w8rh.fsf@nosuchdomain.example.com>
NNTP-Posting-Host: 2001:a61:252a:da01:7c7d:59b9:1662:62f2
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1624447910 1019 2001:a61:252a:da01:7c7d:59b9:1662:62f2 (23 Jun 2021 11:31:50 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Wed, 23 Jun 2021 11:31:50 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Enigmail-Draft-Status: N1110
In-Reply-To: <87y2b1w8rh.fsf@nosuchdomain.example.com>
 by: Janis Papanagnou - Wed, 23 Jun 2021 11:31 UTC

On 23.06.2021 05:38, Keith Thompson wrote:
> Kaz Kylheku <563-365-8930@kylheku.com> writes:
> [...]
>> for x in ./* ; do ...
> [...]
>
> I realize people are quoting articles from upthread, but is there any
> particular reason to write
> for x in ./* ; do ...
> rather than
> for x in * ; do ...
> ?

In this context; not that I know of. Usually that code pattern is used
in contexts where arguments to commands may expand to some looking like
an option (e.g. having a leading '-' in their name) and may thus corrupt
the interpretation of the argument list by the command. (Some commands
have means to prevent that, '--'.) So folks may use the same construct
unnecessarily just because they are used to. (It doesn't hurt anyway.)

Janis

>
> I know it matters in some contexts (for example, "echo *" if the first
> file in the current directory is named "-n"), but it shouldn't matter
> here as far as I can tell.
>

Re: spaces in file names

<savbef$2isdu$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3990&group=comp.unix.shell#3990

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Wed, 23 Jun 2021 13:03:11 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <savbef$2isdu$1@news.xmission.com>
References: <samjbi$q3a$1@reader1.panix.com> <san3rs$mri$1@news-1.m-online.net> <satthq$6kj$1@reader2.panix.com> <sav5mt$ql$1@news-1.m-online.net>
Injection-Date: Wed, 23 Jun 2021 13:03:11 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2716094"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 23 Jun 2021 13:03 UTC

In article <sav5mt$ql$1@news-1.m-online.net>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>On 23.06.2021 01:58, Popping Mad wrote:
>> On 6/20/21 6:04 AM, Janis Papanagnou wrote:
>>> It's beyond me why folks dismiss a correct and efficient
>>> construct (a simple for-loop file pattern) and want to
>>> replace it by wrong and inefficient constructs (subshell
>>> and ls) - ...and then wonder why the code breaks!
>>
>>
>> well, because it is incoherent.
>
>In which mental universe?
>
>> A random ./* in the middle of a shell
>> statement with out an instruction like ls is naked.
>
>I think it makes no sense to discuss your mental picture of a
>"naked construct or shell statement" (or whatever). It makes
>more sense to understand shell syntax and semantics; that is
>something you have to start.

Maybe this is a "boss problem". Maybe his boss doesn't like the accepted
paradigm and prefers "for i in $(ls) ...". I'm guessing that boss saw his
code and told him to change it, so he came here looking for help.

Remember, bosses tend to be set in their ways. That's how they became bosses.
And, I'm actually sympathetic. I can see how the "for i in $(ls) ..."
style just "looks" more "symmetric". If you get used to most lines of code
looking like:

something $(somethingelse)

Then I can see how the other form would be jarring.

Maybe his boss is The Orange One (aka, The Former Guy). He is renowned for
insisting that reality be changed to fit his views, rather than the other
way around. Think: hurricanes in Alabama...

And, remember, as long as the boss is the one signing your paycheck, the
boss is always right.

--
When I was growing up we called them "retards", but that's not PC anymore.
Now, we just call them "Trump Voters".

The question is, of course, how much longer it will be until that term is also un-PC.

Re: spaces in file names

<savj2t$4k9$1@news-1.m-online.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3991&group=comp.unix.shell#3991

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Wed, 23 Jun 2021 17:13:33 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 34
Message-ID: <savj2t$4k9$1@news-1.m-online.net>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net> <satthq$6kj$1@reader2.panix.com>
<sav5mt$ql$1@news-1.m-online.net> <savbef$2isdu$1@news.xmission.com>
NNTP-Posting-Host: 2001:a61:252a:da01:7c7d:59b9:1662:62f2
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1624461213 4745 2001:a61:252a:da01:7c7d:59b9:1662:62f2 (23 Jun 2021 15:13:33 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Wed, 23 Jun 2021 15:13:33 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Enigmail-Draft-Status: N1110
In-Reply-To: <savbef$2isdu$1@news.xmission.com>
 by: Janis Papanagnou - Wed, 23 Jun 2021 15:13 UTC

On 23.06.2021 15:03, Kenny McCormack wrote:
>
> Maybe this is a "boss problem". Maybe his boss doesn't like the accepted
> paradigm and prefers "for i in $(ls) ...". I'm guessing that boss saw his
> code and told him to change it, so he came here looking for help.

To me it sounded more like a hongyi-mindset, i.e. a way of thinking
I have difficulties to get connected to.

> Remember, bosses tend to be set in their ways. That's how they became bosses.
> And, I'm actually sympathetic. I can see how the "for i in $(ls) ..."
> style just "looks" more "symmetric".

Ah, symmetry! - So this must be the solution... (for a problem yet
to be defined)

boss=sob
for ni in rof
do echo ohce od
yes < sey | yes > sey
done # enod

It has the nice property that usually it leads to an error, but a
second call will "suddenly" (as the OP used a formulation) fix it.

In practice; after running it with an error you detect that line 1
is the erroneous one - broken symmetry! - so you install two groups
to try (in the same environment) fixes based on the broken symmetry
hypothesis; one is trying bos=sob and the other boss=ssob . Each
group then "coherently"[OP] observes a success: no error. - q.e.d.
(It obviously was the broken symmetry!)

Janis

Re: spaces in file names

<barmar-EC6F5A.15211426062021@reader.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3992&group=comp.unix.shell#3992

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!barmar.motzarella.org!.POSTED!not-for-mail
From: bar...@alum.mit.edu (Barry Margolin)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sat, 26 Jun 2021 15:21:16 -0400
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <barmar-EC6F5A.15211426062021@reader.eternal-september.org>
References: <samjbi$q3a$1@reader1.panix.com> <86pmwguqr4.fsf@red.stonehenge.com>
Injection-Info: barmar.motzarella.org; posting-host="ab8cce76110b75bbb18d5575f487296d";
logging-data="16308"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DLIcGAb6Ys8GSDrun3rk3"
User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)
Cancel-Lock: sha1:jd65iEboqWDEnkJt/TkrLdmIM2o=
 by: Barry Margolin - Sat, 26 Jun 2021 19:21 UTC

In article <86pmwguqr4.fsf@red.stonehenge.com>,
merlyn@stonehenge.com (Randal L. Schwartz) wrote:

> You think spaces in filenames are weird? I often made a habit of making
> a directory named \n (well, a literal newline) to test my shell scripts.
> I figured if they could deal with a newline, they could probably deal
> with most other things. Also to freak out people peeking at my
> $HOME. :)

If you really want to freak them out, put \r in the filenames.

However, I think recent versions of ls show control characters with
escape sequences by default.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Re: spaces in file names

<eli$2106261736@qaz.wtf>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3993&group=comp.unix.shell#3993

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *...@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Sat, 26 Jun 2021 21:36:07 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2106261736@qaz.wtf>
References: <samjbi$q3a$1@reader1.panix.com> <86pmwguqr4.fsf@red.stonehenge.com> <barmar-EC6F5A.15211426062021@reader.eternal-september.org>
Injection-Date: Sat, 26 Jun 2021 21:36:07 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="13553"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
 by: Eli the Bearded - Sat, 26 Jun 2021 21:36 UTC

In comp.unix.shell, Barry Margolin <barmar@alum.mit.edu> wrote:
> merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>> You think spaces in filenames are weird? I often made a habit of making
>> a directory named \n (well, a literal newline) to test my shell scripts.
>> I figured if they could deal with a newline, they could probably deal
>> with most other things. Also to freak out people peeking at my
>> $HOME. :)

I have heard the autoconf commands get rather out of sorts doing builds
in directories like that. I haven't actually tried, have you?

> If you really want to freak them out, put \r in the filenames.
>
> However, I think recent versions of ls show control characters with
> escape sequences by default.

Yeah, but to me "space" isn't a control character, so I find it somewhat
annoying.

Expert level is entire terminal control sequences in filenames. Not sure
if the Tektronix sequences are short enough to be practical. Here's a
demo of abusing them with `cat`ed files:

https://lock.cmpxchg8b.com/tektronix.html

Elijah
------
found the demo quite funny

Re: spaces in file names

<ik0i20FcpqeU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3994&group=comp.unix.shell#3994

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: josef.mo...@invalid.invalid (Josef Moellers)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Tue, 29 Jun 2021 14:29:52 +0200
Lines: 27
Message-ID: <ik0i20FcpqeU1@mid.individual.net>
References: <samjbi$q3a$1@reader1.panix.com>
<86pmwguqr4.fsf@red.stonehenge.com>
<barmar-EC6F5A.15211426062021@reader.eternal-september.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net CF32SJM+WrQyLh9qtTiU+QAwtBR6NOeyDDe2K8tFYyVDLCPwVl
Cancel-Lock: sha1:1Se705ftEmlquXzl/2oXSenQKI0=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
In-Reply-To: <barmar-EC6F5A.15211426062021@reader.eternal-september.org>
Content-Language: en-US
 by: Josef Moellers - Tue, 29 Jun 2021 12:29 UTC

On 26.06.21 21:21, Barry Margolin wrote:
> In article <86pmwguqr4.fsf@red.stonehenge.com>,
> merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>
>> You think spaces in filenames are weird? I often made a habit of making
>> a directory named \n (well, a literal newline) to test my shell scripts.
>> I figured if they could deal with a newline, they could probably deal
>> with most other things. Also to freak out people peeking at my
>> $HOME. :)
>
> If you really want to freak them out, put \r in the filenames.

<code>
#! /usr/bin/perl

use warnings;
use strict;

my $path = join("\xe2\x88\x95", '', @ARGV);
if (open(my $dst, '>', $path)) {
binmode $dst;
print $dst $path, "\n";
close $dst;
} </code>

Try "script a b c" ;-)

Re: spaces in file names

<sbgbjf$7v3$1@reader1.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3998&group=comp.unix.shell#3998

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www3.mrbrklyn.com!not-for-mail
From: rain...@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Tue, 29 Jun 2021 19:48:48 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <sbgbjf$7v3$1@reader1.panix.com>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net> <san8k2$o5p$2@news-1.m-online.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 29 Jun 2021 23:50:07 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="www3.mrbrklyn.com:96.57.23.83";
logging-data="8163"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
In-Reply-To: <san8k2$o5p$2@news-1.m-online.net>
Content-Language: en-US
 by: Popping Mad - Tue, 29 Jun 2021 23:48 UTC

On 6/20/21 7:25 AM, Janis Papanagnou wrote:
> Oops..
>
> On 20.06.2021 12:04, Janis Papanagnou wrote:
>>
>> What you probably just want is basically
>>
>> for a in ./*.flac
>> do
>> ffmeg ... "$a" ... "${a%flac}.mp3"
>
> ffmeg ... "$a" ... "${a%.flac}.mp3"
>
>> done
>>
>> (add your other ffmpeg options as needed).
>>
>> Janis
>>
>

what is this syntax
"${a%.flac}.mp3"

Re: spaces in file names

<sbgbpt$36v$1@reader1.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3999&group=comp.unix.shell#3999

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www3.mrbrklyn.com!not-for-mail
From: rain...@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: spaces in file names
Date: Tue, 29 Jun 2021 19:52:14 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <sbgbpt$36v$1@reader1.panix.com>
References: <samjbi$q3a$1@reader1.panix.com>
<san3rs$mri$1@news-1.m-online.net> <satthq$6kj$1@reader2.panix.com>
<sau05r$njm$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 29 Jun 2021 23:53:33 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="www3.mrbrklyn.com:96.57.23.83";
logging-data="3295"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
In-Reply-To: <sau05r$njm$1@dont-email.me>
Content-Language: en-US
 by: Popping Mad - Tue, 29 Jun 2021 23:52 UTC

On 6/22/21 8:44 PM, William Unruh wrote:
> You really do not to read what people say.

you really didn't make any contribution to this discussion

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor