shell stuff

Thorsten Glaser <[email protected]>
Newsgroups gmane.comp.web.lynx.devel
Message-ID <[email protected]>
Hi,

while scrolling through a diff to see if I can find the cause
of a regression, I saw this (pasting only one example of it):

source="`echo "$source" | sed -e 's%/$%%'`/"

You m̲u̲s̲t̲ ̲n̲o̲t̲ use double quotes both outside and inside of an
old-style command substitution: some shells pair them as
"`echo " and " | sed -e 's%/$%%'`/" instead of nesting, and
POSIX actively allows that.

Since you never need to quote a command substitution in scalar
context (assignment RHS), this can be easily fixed:

source=`echo "$source" | sed -e 's%/$%%'`/

Can you not use source=${source%/}/ ? (Depends on where you
want to run that script; I know BOW’s /bin/sh fails on that
hard.)

And you might even want:

source=`echo "$source" | sed -e 's%/*/$%%'`/

bye,
//mirabilos
-- 
Gestern Nacht ist mein IRC-Netzwerk explodiert. Ich hatte nicht damit
gerechnet, darum bin ich blutverschmiert… wer konnte ahnen, daß SIE so
reagier’n… gestern Nacht ist mein IRC-Netzwerk explodiert~~~
	(as of 2021-06-15 The MirOS Project temporarily reconvenes on OFTC)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.