Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Bridge ahead. Pay troll.


comp / comp.unix.programmer / Re: Long filenames in DOS/Windows and Unix/Linux

SubjectAuthor
* Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Kenny McCormack
+* Re: Long filenames in DOS/Windows and Unix/LinuxRichard Kettlewell
|+- Re: Long filenames in DOS/Windows and Unix/LinuxMuttley
|`* Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| +* Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| |+- Re: Long filenames in DOS/Windows and Unix/LinuxNuno Silva
| |+- Re: Long filenames in DOS/Windows and Unix/LinuxHelmut Waitzmann
| |+* Re: Long filenames in DOS/Windows and Unix/LinuxWayne
| ||`- Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| |`- Re: Long filenames in DOS/Windows and Unix/LinuxJanis Papanagnou
| `- Arbitrary characters in filenames (was: Long filenames in DOS/Windows and Unix/LHelmut Waitzmann
+* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Muttley
|`* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)John Ames
| +* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Scott Lurndal
| |`- Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Lew Pitcher
| +* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Kenny McCormack
| |`* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping toMuttley
| | `* User surveys (Was: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to)Kenny McCormack
| |  `- Re: User surveys (Was: Long filenames in DOS/Windows and Unix/Linux (Was: PipingMuttley
| +* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Kaz Kylheku
| |`* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)John Ames
| | +* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Kaz Kylheku
| | |`* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)John Ames
| | | +* Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Scott Lurndal
| | | |`- Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Lawrence D'Oliveiro
| | | `* Re: Long filenames in DOS/Windows and Unix/LinuxKeith Thompson
| | |  +* Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| | |  |+- Re: Long filenames in DOS/Windows and Unix/LinuxScott Lurndal
| | |  |`* Re: Long filenames in DOS/Windows and Unix/LinuxKeith Thompson
| | |  | +* Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| | |  | |+* Re: Long filenames in DOS/Windows and Unix/LinuxKeith Thompson
| | |  | ||`* Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| | |  | || `* Re: Long filenames in DOS/Windows and Unix/LinuxKeith Thompson
| | |  | ||  `- Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| | |  | |`* Re: Long filenames in DOS/Windows and Unix/LinuxRalf Fassel
| | |  | | `* Re: Long filenames in DOS/Windows and Unix/LinuxKeith Thompson
| | |  | |  `* Re: Long filenames in DOS/Windows and Unix/LinuxNuno Silva
| | |  | |   `* Always use "--" (Was: Long filenames in DOS/Windows and Unix/Linux)Kenny McCormack
| | |  | |    `* Re: Always use "--" (Was: Long filenames in DOS/Windows and Unix/Linux)Lew Pitcher
| | |  | |     +- Re: Always use "--" (Was: Long filenames in DOS/Windows and Unix/Linux)Lawrence D'Oliveiro
| | |  | |     `* Re: Always use "--" (Was: Long filenames in DOS/Windows and Unix/Linux)Kaz Kylheku
| | |  | |      `- Re: Always use "--" (Was: Long filenames in DOS/Windows and Unix/Linux)Lew Pitcher
| | |  | `- Re: Long filenames in DOS/Windows and Unix/LinuxTim Rentsch
| | |  +* Re: Long filenames in DOS/Windows and Unix/LinuxKaz Kylheku
| | |  |+* Re: Long filenames in DOS/Windows and Unix/LinuxKeith Thompson
| | |  ||`* Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| | |  || `* Re: Long filenames in DOS/Windows and Unix/LinuxKeith Thompson
| | |  ||  +* Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| | |  ||  |`* Re: Long filenames in DOS/Windows and Unix/LinuxKeith Thompson
| | |  ||  | +- Re: Long filenames in DOS/Windows and Unix/LinuxLawrence D'Oliveiro
| | |  ||  | `- Re: Long filenames in DOS/Windows and Unix/LinuxNuno Silva
| | |  ||  `- Re: Long filenames in DOS/Windows and Unix/LinuxKaz Kylheku
| | |  |`* Re: Long filenames in DOS/Windows and Unix/LinuxJohn Ames
| | |  | `- Re: Long filenames in DOS/Windows and Unix/LinuxMuttley
| | |  `* Re: Long filenames in DOS/Windows and Unix/LinuxRichard Kettlewell
| | |   `* Re: Long filenames in DOS/Windows and Unix/LinuxRalf Fassel
| | |    +* Re: Long filenames in DOS/Windows and Unix/LinuxRichard Kettlewell
| | |    |`* Re: Long filenames in DOS/Windows and Unix/Linuxcandycanearter07
| | |    | `- Word splitting oddities (Was: Long filenames in DOS/Windows and Unix/Linux)Kenny McCormack
| | |    `- Re: Long filenames in DOS/Windows and Unix/LinuxJanis Papanagnou
| | `- Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Janis Papanagnou
| `- Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping toMuttley
`- Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)Marcel Mueller

Pages:123
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
From: John Ames
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Wed, 4 Sep 2024 15:41 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: commodorejohn@gmail.com (John Ames)
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Wed, 4 Sep 2024 08:41:03 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <20240904084103.00001575@gmail.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<ubg6o7$3jrsn$1@news.xmission.com>
<ubg853$2ssj8$1@dont-email.me>
<ubg8a8$2t20l$1@dont-email.me>
<vaubbo$1d324$1@news.xmission.com>
<vauknd$uvji$1@dont-email.me>
<20240903084440.0000663d@gmail.com>
<20240903103327.395@kylheku.com>
<20240903113937.000008a3@gmail.com>
<20240903130000.933@kylheku.com>
<20240903132547.00000656@gmail.com>
<87seug1iyj.fsf@nosuchdomain.example.com>
<20240903155649.659@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 04 Sep 2024 17:41:08 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="96a3b450c540f165cc71dff3acf98e7d";
logging-data="4082710"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+bctg8kjkrDAB2ribTc4qBzmBnPwyMBWo="
Cancel-Lock: sha1:e5T5c6rIvQb3F5q5srTKgJ864m4=
X-Newsreader: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-w64-mingw32)
View all headers

On Tue, 3 Sep 2024 23:15:46 -0000 (UTC)
Kaz Kylheku <643-408-1753@kylheku.com> wrote:

> The make utility has no support for paths with spaces.
>
> Use of make is a great repellant against spaces in names.
>
> If a make variable contains spaces, there is no way to quote it within
> make. There is no way to express a prerequisite or target name with
> spaces. GNU Make text processing constructs like $(foreach ...)
> don't deal with spaces; there is no way for them to identify items
> that contain spaces.

If the make utility has no provisions for coping with a subset of legal
filenames, that would seem to be a deficiency in make.

Subject: Re: Long filenames in DOS/Windows and Unix/Linux
From: Muttley@dastardlyhq.com
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Wed, 4 Sep 2024 15:57 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Muttley@dastardlyhq.com
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Wed, 4 Sep 2024 15:57:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <vba014$3t58j$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<ubg6o7$3jrsn$1@news.xmission.com>
<ubg853$2ssj8$1@dont-email.me>
<ubg8a8$2t20l$1@dont-email.me>
<vaubbo$1d324$1@news.xmission.com>
<vauknd$uvji$1@dont-email.me>
<20240903084440.0000663d@gmail.com>
<20240903103327.395@kylheku.com>
<20240903113937.000008a3@gmail.com>
<20240903130000.933@kylheku.com>
<20240903132547.00000656@gmail.com>
<87seug1iyj.fsf@nosuchdomain.example.com>
<20240903155649.659@kylheku.com>
<20240904084103.00001575@gmail.com>
Injection-Date: Wed, 04 Sep 2024 17:57:25 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="37739d3d5fcdae2aede8678d1d7dbc6b";
logging-data="4101395"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+bKj/t8rQlkd9yyV9mys6M"
Cancel-Lock: sha1:045LcQ4sE2LAQtCvs2BtW4/Iq5M=
View all headers

On Wed, 4 Sep 2024 08:41:03 -0700
John Ames <commodorejohn@gmail.com> boringly babbled:
>On Tue, 3 Sep 2024 23:15:46 -0000 (UTC)
>Kaz Kylheku <643-408-1753@kylheku.com> wrote:
>
>> The make utility has no support for paths with spaces.
>>
>> Use of make is a great repellant against spaces in names.
>>
>> If a make variable contains spaces, there is no way to quote it within
>> make. There is no way to express a prerequisite or target name with
>> spaces. GNU Make text processing constructs like $(foreach ...)
>> don't deal with spaces; there is no way for them to identify items
>> that contain spaces.
>
>If the make utility has no provisions for coping with a subset of legal
>filenames, that would seem to be a deficiency in make.

Given 99.99% of make use cases are to build binaries from source code and
no sane person would put spaces in the filenames of either, I doubt the
developers of make or its users could care less.

Subject: Re: Long filenames in DOS/Windows and Unix/Linux
From: Richard Kettlewell
Newsgroups: comp.unix.programmer
Organization: terraraq NNTP server
Date: Wed, 4 Sep 2024 17:03 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.gegeweb.eu!gegeweb.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Wed, 04 Sep 2024 18:03:27 +0100
Organization: terraraq NNTP server
Message-ID: <wwvcylj73mo.fsf@LkoBDZeT.terraraq.uk>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<ubg6o7$3jrsn$1@news.xmission.com> <ubg853$2ssj8$1@dont-email.me>
<ubg8a8$2t20l$1@dont-email.me> <vaubbo$1d324$1@news.xmission.com>
<vauknd$uvji$1@dont-email.me> <20240903084440.0000663d@gmail.com>
<20240903103327.395@kylheku.com> <20240903113937.000008a3@gmail.com>
<20240903130000.933@kylheku.com> <20240903132547.00000656@gmail.com>
<87seug1iyj.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="62307"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:eowTbnMOhlx5YWYSeftj8eYBCiM=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
View all headers

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Spaces in file names are likely not to be an issue if you interact
> with the filesystem via a GUI like Windows Explorer *or* if you use
> a scripting language like Perl or Python that requires strings used
> as filenames to be enclosed in quotation marks. In those contexts,
> space is just another character.
>
> It can be a real issue if you're interacting via shell commands.
> If I happen to know that none of the files I'm working with have
> spaces (or other problematic characters) in their names, a lot of
> things become easier -- but risky if there's a funny character I'm
> not aware of. For example, I might type something like:
>
> for file in * ; do cp -p $file $file.bak ; done

That’s the heart of the matter. Field splitting happens after parameter
expansion. The languages that don’t have trouble with spaces in
filenames[1] don’t do it that way. I suspect if some different design
decisions had been made long ago, nobody would be inferring from the
difficulties shell scripts have handling strings with spaces in that
they were unnecessary or even forbidden in filenames.

[1] or any other kind of string. Let’s not get tunnel vision about
filenames: shell has trouble with spaces in other contexts too.

Tcl is the most instructive example: it has a similar word-base
structure to shell, but largely without getting into the same tangles
over spaces.

> It would be ideal, I suppose, if interactive shells dealt better with
> spaces in file names, but I'm not sure how that could be achieved. In
> current shells, removing two files named "foo" and "bar" is easy, and
> removing a single file named "foo bar" requires some extra effort. I
> find that to be a good tradeoff.

Agreed. I note that tab completion normally adds any quotes needed,
which deals with most of the issues in interactive mode, for me.

As well as the above observations about shell syntax we could also
wonder whether it was ever really necessary to use the same syntax both
for interactive file management and a programming language.

--
https://www.greenend.org.uk/rjk/

Subject: Re: Always use "--" (Was: Long filenames in DOS/Windows and Unix/Linux)
From: Lawrence D'Oliv
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Wed, 4 Sep 2024 21:35 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.programmer
Subject: Re: Always use "--" (Was: Long filenames in DOS/Windows and
Unix/Linux)
Date: Wed, 4 Sep 2024 21:35:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <vbajqa$3a4$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<yga34mfoily.fsf@akutech.de> <87ttevzoj3.fsf@nosuchdomain.example.com>
<vb9k2l$3r705$1@dont-email.me> <vb9ls7$1igeo$1@news.xmission.com>
<vb9mls$3rk17$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 04 Sep 2024 23:35:07 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="176f5fbfb5d1157be6fd816dae78eee8";
logging-data="3396"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YAUgnrhcl4x/q20eZ497B"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:IUK2SRze0HbtWrB8d1hvcEKwKN0=
View all headers

On Wed, 4 Sep 2024 13:17:48 -0000 (UTC), Lew Pitcher wrote:

> The "--" option is just that, an option coded into the argument parser
> of the program being invoked. Many programs /do not/ recognize "--" as
> an "end of flags" argument, so the effectiveness of "--" is unreliable.

All the good ones do. This is why getopt(3) with POSIXLY_CORRECT stops
looking for options as soon as a nonoption argument is encountered.

Remember also that arguments need not necessarily be file names, so
prefixing them all with “./” willy-nilly may not produce the right result
anyway.

Subject: Re: Always use "--" (Was: Long filenames in DOS/Windows and Unix/Linux)
From: Kaz Kylheku
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Thu, 5 Sep 2024 02:29 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.programmer
Subject: Re: Always use "--" (Was: Long filenames in DOS/Windows and
Unix/Linux)
Date: Thu, 5 Sep 2024 02:29:49 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <20240904192549.23@kylheku.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<yga34mfoily.fsf@akutech.de> <87ttevzoj3.fsf@nosuchdomain.example.com>
<vb9k2l$3r705$1@dont-email.me> <vb9ls7$1igeo$1@news.xmission.com>
<vb9mls$3rk17$1@dont-email.me>
Injection-Date: Thu, 05 Sep 2024 04:29:49 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4d4bbe75f0388a771dfebf259ca2980f";
logging-data="198221"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rI1JqZZHFKEzHc+lJzIhqhQIdrgZnX3M="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:dQFXUlmLeOy/9owJumqrRMlvd+A=
View all headers

On 2024-09-04, Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
> On Wed, 04 Sep 2024 13:04:07 +0000, Kenny McCormack wrote:
>
>> In article <vb9k2l$3r705$1@dont-email.me>,
>> Nuno Silva <nunojsilva@invalid.invalid> wrote:
>> ...
>>>> D'oh!
>>>
>>>(Along with these quotes, I'd add ./ before $file.)
>>
>> Or, more simply, just put -- after the -p.
>>
>> This is an often overlooked aspect of shell programing. You should always
>> use "--". The "shellcheck" program will tell you this, if you let it.
>
> The "--" option is just that, an option coded into the argument parser of
> the program being invoked. Many programs /do not/ recognize "--" as an
> "end of flags" argument, so the effectiveness of "--" is unreliable.
>
> OTOH, if you specify a fully qualified pathname, (or, at least, a qualified
> relative pathname), you can assure yourself that the file path provided
> to the program /will not/ start with the '-' that indicates a program flag.
>
> Note that all this is /convention/ and not /requirement/. There are situations
> in which /none/ of the above applies, as
> a) the program interprets it's arguments by /position/, or
> b) the program doesn't use the '-' to introduce flag arguments, or
> c) the program doesn't take filenames as arguments, or
> d) some other conditions that I'm too lazy to enumerate

d) it's a goddamned GNU program that continues to take options
after non-option arguments!

$ ls . -ld
drwxr-xr-x 67 kaz kaz 36864 Sep 3 15:59 .

.... unless -- is specified to signal the end of options.

$ ls -ld -- . -ld
ls: cannot access '-ld': No such file or directory
drwxr-xr-x 67 kaz kaz 36864 Sep 3 15:59 .

So unfortunately although starting an argument with ./ will
ensure that it's not treated as an option, it doesn't mean
it will be treated as the first non-option argument after
which there are no more option arguments.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: Long filenames in DOS/Windows and Unix/Linux
From: Ralf Fassel
Newsgroups: comp.unix.programmer
Date: Thu, 5 Sep 2024 09:29 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Thu, 05 Sep 2024 11:29:14 +0200
Lines: 38
Message-ID: <ygay146mot1.fsf@akutech.de>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<ubg6o7$3jrsn$1@news.xmission.com> <ubg853$2ssj8$1@dont-email.me>
<ubg8a8$2t20l$1@dont-email.me> <vaubbo$1d324$1@news.xmission.com>
<vauknd$uvji$1@dont-email.me> <20240903084440.0000663d@gmail.com>
<20240903103327.395@kylheku.com> <20240903113937.000008a3@gmail.com>
<20240903130000.933@kylheku.com> <20240903132547.00000656@gmail.com>
<87seug1iyj.fsf@nosuchdomain.example.com>
<wwvcylj73mo.fsf@LkoBDZeT.terraraq.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net tnjjGm02ApXG0PFJO3o7rwbVRmgBGBDxrNw8F409LF7KdO4Oc=
Cancel-Lock: sha1:uftCNBoGKK0Ra65YhKNeJUBqe84= sha1:ZUSsjt89IIEYzmo7pjZ7CJd6LtM= sha256:w3soWT94+fn93MKGiCTfJjh2t8TEzeHCsfF3/PK6xDs=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
View all headers

* Richard Kettlewell <invalid@invalid.invalid>
| Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
| > [...] For example, I might type something like:
| >
| > for file in * ; do cp -p $file $file.bak ; done
>
| That’s the heart of the matter. Field splitting happens after parameter
| expansion.

Only sometimes it doesn't :-)

$ foo="foo bar"
$ bar=$foo

No problem with the space in the expanded value here!

$ echo $bar
foo bar

but of course:
ls $bar
ls: cannot access 'foo': No such file or directory
ls: cannot access 'bar': No such file or directory

It's documented in bash(1):

PARAMETERS
[...]
A variable may be assigned to by a statement of the form

name=[value]

[...] Word splitting is not performed, with the exception of
"$@" as explained below under Special Parameters.

but I find it confusing nevertheless.

R'

Subject: Re: Always use "--" (Was: Long filenames in DOS/Windows and Unix/Linux)
From: Lew Pitcher
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Thu, 5 Sep 2024 14:48 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitcher@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.programmer
Subject: Re: Always use "--" (Was: Long filenames in DOS/Windows and
Unix/Linux)
Date: Thu, 5 Sep 2024 14:48:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <vbcgbu$cc45$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<yga34mfoily.fsf@akutech.de> <87ttevzoj3.fsf@nosuchdomain.example.com>
<vb9k2l$3r705$1@dont-email.me> <vb9ls7$1igeo$1@news.xmission.com>
<vb9mls$3rk17$1@dont-email.me> <20240904192549.23@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 05 Sep 2024 16:48:31 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c4741b9aab2f3ab481d100c5a665b386";
logging-data="405637"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bHm7k2HBS3Qk6xkJn3Ry4xb7DMXTE9xA="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:vqtTFHYcu7pUloCagVKyo6gpcc0=
View all headers

On Thu, 05 Sep 2024 02:29:49 +0000, Kaz Kylheku wrote:

> On 2024-09-04, Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>> On Wed, 04 Sep 2024 13:04:07 +0000, Kenny McCormack wrote:
>>
>>> In article <vb9k2l$3r705$1@dont-email.me>,
>>> Nuno Silva <nunojsilva@invalid.invalid> wrote:
>>> ...
>>>>> D'oh!
>>>>
>>>>(Along with these quotes, I'd add ./ before $file.)
>>>
>>> Or, more simply, just put -- after the -p.
>>>
>>> This is an often overlooked aspect of shell programing. You should always
>>> use "--". The "shellcheck" program will tell you this, if you let it.
>>
>> The "--" option is just that, an option coded into the argument parser of
>> the program being invoked. Many programs /do not/ recognize "--" as an
>> "end of flags" argument, so the effectiveness of "--" is unreliable.
>>
>> OTOH, if you specify a fully qualified pathname, (or, at least, a qualified
>> relative pathname), you can assure yourself that the file path provided
>> to the program /will not/ start with the '-' that indicates a program flag.
>>
>> Note that all this is /convention/ and not /requirement/. There are situations
>> in which /none/ of the above applies, as
>> a) the program interprets it's arguments by /position/, or
>> b) the program doesn't use the '-' to introduce flag arguments, or
>> c) the program doesn't take filenames as arguments, or
>> d) some other conditions that I'm too lazy to enumerate
>
> d) it's a goddamned GNU program that continues to take options
> after non-option arguments!
>
> $ ls . -ld
> drwxr-xr-x 67 kaz kaz 36864 Sep 3 15:59 .
>
> ... unless -- is specified to signal the end of options.
>
> $ ls -ld -- . -ld
> ls: cannot access '-ld': No such file or directory
> drwxr-xr-x 67 kaz kaz 36864 Sep 3 15:59 .
>
> So unfortunately although starting an argument with ./ will
> ensure that it's not treated as an option, it doesn't mean
> it will be treated as the first non-option argument after
> which there are no more option arguments.

That seems to be a symptom of the use of the GNU variant of
the POSIX getopt(3) function.
"By default, [GNU] getopt() permutes the contents of argv as it scans, so that
eventually all the nonoptions are at the end. Two other modes are also
implemented. If the first character of optstring is '+' or the envi-
ronment variable POSIXLY_CORRECT is set, then option processing stops
as soon as a nonoption argument is encountered."

The "workaround" seems to be to set the POSIXLY_CORRECT envvar as part of
your standard environment.

--
Lew Pitcher
"In Skills We Trust"

Subject: Re: Long filenames in DOS/Windows and Unix/Linux
From: Richard Kettlewell
Newsgroups: comp.unix.programmer
Organization: terraraq NNTP server
Date: Thu, 5 Sep 2024 17:21 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.gegeweb.eu!gegeweb.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Thu, 05 Sep 2024 18:21:15 +0100
Organization: terraraq NNTP server
Message-ID: <wwvy1463tkk.fsf@LkoBDZeT.terraraq.uk>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<ubg6o7$3jrsn$1@news.xmission.com> <ubg853$2ssj8$1@dont-email.me>
<ubg8a8$2t20l$1@dont-email.me> <vaubbo$1d324$1@news.xmission.com>
<vauknd$uvji$1@dont-email.me> <20240903084440.0000663d@gmail.com>
<20240903103327.395@kylheku.com> <20240903113937.000008a3@gmail.com>
<20240903130000.933@kylheku.com> <20240903132547.00000656@gmail.com>
<87seug1iyj.fsf@nosuchdomain.example.com>
<wwvcylj73mo.fsf@LkoBDZeT.terraraq.uk> <ygay146mot1.fsf@akutech.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="86201"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:+VjjXbUrWUlf5bRFp8qqCqmKjBM=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
View all headers

Ralf Fassel <ralfixx@gmx.de> writes:
> * Richard Kettlewell <invalid@invalid.invalid>
> | Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> | > [...] For example, I might type something like:
> | >
> | > for file in * ; do cp -p $file $file.bak ; done
> |
> | That’s the heart of the matter. Field splitting happens after
> | parameter expansion.
>
> Only sometimes it doesn't :-)
>
> $ foo="foo bar"
> $ bar=$foo
>
> No problem with the space in the expanded value here!
>
> $ echo $bar
> foo bar
>
> but of course:
> ls $bar
> ls: cannot access 'foo': No such file or directory
> ls: cannot access 'bar': No such file or directory

Fair point. “Field splitting happens after parameter expansion, except
when it doesn’t”.

--
https://www.greenend.org.uk/rjk/

Subject: Re: Long filenames in DOS/Windows and Unix/Linux
From: candycanearter07
Newsgroups: comp.unix.programmer
Organization: the-candyden-of-code
Date: Sat, 7 Sep 2024 18:20 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: candycanearter07@candycanearter07.nomail.afraid (candycanearter07)
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Sat, 7 Sep 2024 18:20:03 -0000 (UTC)
Organization: the-candyden-of-code
Lines: 43
Message-ID: <slrnvdp692.1s5hi.candycanearter07@candydeb.host.invalid>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<ubg6o7$3jrsn$1@news.xmission.com> <ubg853$2ssj8$1@dont-email.me>
<ubg8a8$2t20l$1@dont-email.me> <vaubbo$1d324$1@news.xmission.com>
<vauknd$uvji$1@dont-email.me> <20240903084440.0000663d@gmail.com>
<20240903103327.395@kylheku.com> <20240903113937.000008a3@gmail.com>
<20240903130000.933@kylheku.com> <20240903132547.00000656@gmail.com>
<87seug1iyj.fsf@nosuchdomain.example.com>
<wwvcylj73mo.fsf@LkoBDZeT.terraraq.uk> <ygay146mot1.fsf@akutech.de>
<wwvy1463tkk.fsf@LkoBDZeT.terraraq.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 07 Sep 2024 20:20:03 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b640cdd4c5fc632cfffdc5cd9571c38f";
logging-data="1556951"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18L7craMo2rs5szZlB2QcItNaz/2KAJa7u8S3C9rRGC4A=="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:Hd3rNm5FbezYngfaGGNFn5I2Jpc=
X-Face: b{dPmN&%4|lEo,wUO\"KLEOu5N_br(N2Yuc5/qcR5i>9-!^e\.Tw9?/m0}/~:UOM:Zf]%
b+ V4R8q|QiU/R8\|G\WpC`-s?=)\fbtNc&=/a3a)r7xbRI]Vl)r<%PTriJ3pGpl_/B6!8pe\btzx
`~R! r3.0#lHRE+^Gro0[cjsban'vZ#j7,?I/tHk{s=TFJ:H?~=]`O*~3ZX`qik`b:.gVIc-[$t/e
ZrQsWJ >|l^I_[pbsIqwoz.WGA]<D
View all headers

Richard Kettlewell <invalid@invalid.invalid> wrote at 17:21 this Thursday (GMT):
> Ralf Fassel <ralfixx@gmx.de> writes:
>> * Richard Kettlewell <invalid@invalid.invalid>
>> | Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> | > [...] For example, I might type something like:
>> | >
>> | > for file in * ; do cp -p $file $file.bak ; done
>> |
>> | That’s the heart of the matter. Field splitting happens after
>> | parameter expansion.
>>
>> Only sometimes it doesn't :-)
>>
>> $ foo="foo bar"
>> $ bar=$foo
>>
>> No problem with the space in the expanded value here!
>>
>> $ echo $bar
>> foo bar
>>
>> but of course:
>> ls $bar
>> ls: cannot access 'foo': No such file or directory
>> ls: cannot access 'bar': No such file or directory
>
> Fair point. “Field splitting happens after parameter expansion, except
> when it doesn’t”.

Actually, echo is special since it just prints every argument it's
given.. both of these commands are working as expected with splitting:

$ echo some text

some text

$ ls some text

ls: cannot access 'some': No such file or directory
ls: cannot access 'text': No such file or directory
--
user <candycane> is generated from /dev/urandom

Subject: Word splitting oddities (Was: Long filenames in DOS/Windows and Unix/Linux)
From: Kenny McCormack
Newsgroups: comp.unix.programmer
Organization: The official candy of the new Millennium
Date: Sat, 7 Sep 2024 21:51 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.programmer
Subject: Word splitting oddities (Was: Long filenames in DOS/Windows and Unix/Linux)
Date: Sat, 7 Sep 2024 21:51:29 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vbiht0$1mt5p$1@news.xmission.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com> <ygay146mot1.fsf@akutech.de> <wwvy1463tkk.fsf@LkoBDZeT.terraraq.uk> <slrnvdp692.1s5hi.candycanearter07@candydeb.host.invalid>
Injection-Date: Sat, 7 Sep 2024 21:51:29 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1799353"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <slrnvdp692.1s5hi.candycanearter07@candydeb.host.invalid>,
candycanearter07 <candycanearter07@candycanearter07.nomail.afraid> wrote:
....
>>> Only sometimes it doesn't :-)
>>>
>>> $ foo="foo bar"
>>> $ bar=$foo
>>>
>>> No problem with the space in the expanded value here!
>>>
>>> $ echo $bar
>>> foo bar
>>>
>>> but of course:
>>> ls $bar
>>> ls: cannot access 'foo': No such file or directory
>>> ls: cannot access 'bar': No such file or directory
>>
>> Fair point. Field splitting happens after parameter expansion, except
>> when it doesnt.
>
>
>Actually, echo is special since it just prints every argument it's
>given.. both of these commands are working as expected with splitting:
>
> $ echo some text
>
> some text
>
> $ ls some text
>
> ls: cannot access 'some': No such file or directory
> ls: cannot access 'text': No such file or directory

The point is still valid, even if the demonstration wasn't quite on-point.

When faced with the problem of needing to display a variable in shell, but
needing to know whether or not it is a single string or multiple strings, a
useful trick is to use "printf" like this:

$ set -- this is "a test of" something
$ printf "%s\n" "$@"

Then you would know for sure that in the example above, the variable "foo"
really did have the value "foo bar".

Note, incidentally, that in the example above, the statement: bar=$foo
pretty much has to be parsed as if $foo had been quoted, because the
alternative is much worse. The alternative would be to interpret:

bar=$foo
as
bar=foo bar

which means to run the "bar" command with the env var "bar" set to "foo".

--
Trump has normalized hate.

The media has normalized Trump.

Subject: Re: Long filenames in DOS/Windows and Unix/Linux
From: Janis Papanagnou
Newsgroups: comp.unix.programmer, comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 8 Sep 2024 05:24 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.programmer,comp.unix.shell
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Sun, 8 Sep 2024 07:24:02 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <vbjcdj$1qrgd$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<ubg6o7$3jrsn$1@news.xmission.com> <ubg853$2ssj8$1@dont-email.me>
<ubg8a8$2t20l$1@dont-email.me> <vaubbo$1d324$1@news.xmission.com>
<wwv34mlm70f.fsf@LkoBDZeT.terraraq.uk> <vb099u$162j5$10@dont-email.me>
<vb13k3$1dlt4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 08 Sep 2024 07:24:04 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cedab109241535991cb224f8b499cda5";
logging-data="1928717"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5pvBMOlSlmOaCc/A61PGd"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:YiB0JgbDe5nZfXWI9gv1e6ld0qk=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <vb13k3$1dlt4$1@dont-email.me>
View all headers

On 01.09.2024 09:03, Lawrence D'Oliveiro wrote:
> I wrote:
>
>> If you avoid newlines in filenames, Posix shells can cope with anything
>> else if you set “IFS=$'\n'”.
>
> Sorry, no, it looks like the “$'...'” syntax for string literals is not
> from Posix, it’s a Bash-ism.

Note that it's not a "Bash-ism" - Bash was rarely the _inventor_ of
any shell features, mostly adopted them from other shells, primarily
from Kornshell (still, by far, not catching up).

Kornshell documented that specific feature with its 1993 version.

And we've learned from other replies that it's meanwhile - 30 years
later - already in POSIX. (Good news!)

Janis

Subject: Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to stdin)
From: Janis Papanagnou
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Tue, 10 Sep 2024 04:51 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux (Was: Piping to
stdin)
Date: Tue, 10 Sep 2024 06:51:53 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <vboj9a$2pmrj$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<ubg6o7$3jrsn$1@news.xmission.com> <ubg853$2ssj8$1@dont-email.me>
<ubg8a8$2t20l$1@dont-email.me> <vaubbo$1d324$1@news.xmission.com>
<vauknd$uvji$1@dont-email.me> <20240903084440.0000663d@gmail.com>
<20240903103327.395@kylheku.com> <20240903113937.000008a3@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Sep 2024 06:51:54 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="924a7b5cdcacf972d784a2302a9c8dba";
logging-data="2939763"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xWfn/hBg9R3udLjueaCrb"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:a9dY3MXCD4cB031ftHhux3mLS9c=
In-Reply-To: <20240903113937.000008a3@gmail.com>
X-Enigmail-Draft-Status: N1110
View all headers

On 03.09.2024 20:39, John Ames wrote:
> [...]
> Also, who says that filenames should not, as a rule, contain spaces?

Technically, filenames may even contain ASCII control characters.
Is it wise to use them?

Semantically I'd interpret the term "file name" (and its original
intention) as something different from, erm.., a "file novel".
(I don't want to write "novels" to work with them [in non-GUIs].
I want to spot differences easily, not have to parse the name.)

A file [content] "description" is different from a file "name".
(Note: above term "novel" was just a rhetoric accentuation of
"description".)

The descriptions that some folks stuff into a "file name" should
IMO be part of a file's _meta-information_!
(BTW, like the file's "extension" IMO would also belong there,
like other formal or informal type information about the file.)

It's a historic heritage what we have (strange, OS/FS-dependent,
arbitrary, non-portable, error-prone, etc.). Tedious to discuss.

Define your own standards... - and then live (or die) with them!

Janis

Subject: Re: Long filenames in DOS/Windows and Unix/Linux
From: Janis Papanagnou
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Tue, 10 Sep 2024 05:17 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Tue, 10 Sep 2024 07:17:48 +0200
Organization: A noiseless patient Spider
Lines: 71
Message-ID: <vbokpu$2ptqu$1@dont-email.me>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
<ubg6o7$3jrsn$1@news.xmission.com> <ubg853$2ssj8$1@dont-email.me>
<ubg8a8$2t20l$1@dont-email.me> <vaubbo$1d324$1@news.xmission.com>
<vauknd$uvji$1@dont-email.me> <20240903084440.0000663d@gmail.com>
<20240903103327.395@kylheku.com> <20240903113937.000008a3@gmail.com>
<20240903130000.933@kylheku.com> <20240903132547.00000656@gmail.com>
<87seug1iyj.fsf@nosuchdomain.example.com>
<wwvcylj73mo.fsf@LkoBDZeT.terraraq.uk> <ygay146mot1.fsf@akutech.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 10 Sep 2024 07:17:50 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="78d7bf36bc8ee21db1497a685bf07eeb";
logging-data="2946910"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LeQfRiPWKzVwgDI+na4+Y"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:dq6ZjylT0s6NZ+cjPDcBbdczB70=
In-Reply-To: <ygay146mot1.fsf@akutech.de>
X-Enigmail-Draft-Status: N1110
View all headers

On 05.09.2024 11:29, Ralf Fassel wrote:
> * Richard Kettlewell <invalid@invalid.invalid>
> | Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> | > [...] For example, I might type something like:
> | >
> | > for file in * ; do cp -p $file $file.bak ; done

Quoting is generally the standard way to be on the safe side...

for file in * ; do cp -p "$file" "$file.bak" ; done

> | That’s the heart of the matter. Field splitting happens after parameter
> | expansion.
>
> Only sometimes it doesn't :-)
>
> $ foo="foo bar"
> $ bar=$foo
>
> No problem with the space in the expanded value here!
>
> $ echo $bar
> foo bar

There is a problem also with 'echo'...!

space="foo bar"
two_spaces="two spaces"
a_tab="a tab"

# all the IFSs get collapsed in:
echo $space
echo $two_spaces
echo $a_tab

# correct way to handle that:
echo "$space"
echo "$two_spaces"
echo "$a_tab"

>
> but of course:
> ls $bar
> ls: cannot access 'foo': No such file or directory
> ls: cannot access 'bar': No such file or directory
>
> It's documented in bash(1):
>
> PARAMETERS
> [...]
> A variable may be assigned to by a statement of the form
>
> name=[value]
>
> [...] Word splitting is not performed, with the exception of
> "$@" as explained below under Special Parameters.
>
> but I find it confusing nevertheless.

It's not that confusing if you know the difference between a shell
construct (that doesn't require quotes) and "the all rest" that
needs (for the general case) quotes. If in doubt there's the rule
of thumb to always use quotes.

Janis

>
> R'
>

Pages:123

rocksolid light 0.9.8
clearnet tor