Deutsch   English   Français   Italiano  
<m9ugkgFmj4sU1@mid.individual.net>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Martijn Dekker <martijn@inlv.demon.nl>
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Warning: pipe symbol within ${} should be quoted?
Date: Fri, 30 May 2025 20:52:48 +0100
Lines: 61
Message-ID: <m9ugkgFmj4sU1@mid.individual.net>
References: <vvgomq$1a3rb$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net Uv0senwUA9XV7fwMNPSkrA+dNAScSOZykP1WJP9BRDkkIOs+w=
Cancel-Lock: sha1:fjf7J69dunbY9SQUH3CRyuCysjs= sha256:7c0Yv5ZQNpRY7amZlajU/1eWx+zssnnCf9y5+yCfMO4=
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <vvgomq$1a3rb$1@dont-email.me>
Bytes: 2592

Op 08-05-2025 om 00:00 schreef Janis Papanagnou:
> With syntax-check ('ksh -n') I get a warning in Ksh for this expression
> 
>    "${pipe#* | }"
> 
> concerning the pipe symbol. (Bash and Zsh don't complain.)

But bash and zsh don't offer linter functionality with -n at all, do they?

> (2709)$ ksh -n -c '"${pipe#* | }"'
> ksh: warning: line 1: | within ${} should be quoted

ksh -n currently produces the warning in this context for these characters:
& < > |

There is nothing in the POSIX shell grammar that suggests these should be 
quoted there. The string between # and } is a shell pattern, and those are not 
special characters in POSIX shell patterns.

While ksh does support extended shell pattern syntax in which & and | may be 
metacharacters, those characters are not special unless that extended shell 
pattern syntax is actually used (in which case you don't want to quote them if 
you want them to be metacharacters). And < and > are never special in patterns 
at all.

My conclusion is that this warning is unhelpful. I'll remove it.

By the way, a little test script shows that old ksh versions had some bugs here:

	pipe="one | two"
	echo "${pipe#* | }"
	pipe="one & two"
	echo "${pipe#* & }"
	pipe="one < two"
	echo "${pipe#* < }"
	pipe="one > two"
	echo "${pipe#* > }"

Output on ksh 93u+ 2012-08-01, the last "stable" AT&T release:

	| two
	one & two
	two
	two

Output on ksh 93u+m as of 2022-02-08 (as well as AT&T ksh as of 93v- 
2012-08-24 beta):

	two
	two
	two
	two

I believe the latter is the correct output.

-- 
||    modernish -- harness the shell
||    https://github.com/modernish/modernish
||
||    KornShell lives!
||    https://github.com/ksh93/ksh