🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1682

Problem with sh/ksh quoting

#1682
From: Kenneth Herron
Date: Wed, 31 Oct 1990 03:14
42 lines
1296 bytes
I'm having a problem with quoting in shell scripts, exemplified by
the following:

line="this is 'a test'"

for word in $line
do
	echo $word
done

I *want* it to produce:
this
is
a test

but it produces:
this
is
'a
test'

I've tried some variations:
line='this is ''a test'''

line="this is \'a test\'"

temp='a test'
line="this is $temp"

temp='a test'
line="this is '$temp'"

and so on, but either the final set of quotes are stripped out, or not
recognized (as above), or the temp variable isn't expanded, or just about
anything but what I want.  Eval didn't seem to help, nor did quoting the
space within 'a test'.  Does anyone know how to accomplish this?

(BTW, what I'm REALLY trying to do is set options to a command (less) 
where one of the options (the -P prompt option) takes an argument with
spaces.)

Kenneth Herron
Technical Details
Message-ID: <16289@s.ms.uky.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!timbuk!cs.umn.edu!msi.umn.edu!src.honeywell.com!sol.ctr.columbia.edu!emory!gatech!ukma!kherron

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!timbuk!cs.umn.edu!msi.umn.edu!src.honeywell.com!sol.ctr.columbia.edu!emory!gatech!ukma!kherron
From: kherron@ms.uky.edu (Kenneth Herron)
Newsgroups: comp.unix.shell
Subject: Problem with sh/ksh quoting
Message-ID: <16289@s.ms.uky.edu>
Date: 31 Oct 90 03:14:42 GMT
Reply-To: kherron@ms.uky.edu (Kenneth Herron)
Distribution: na
Organization: U of Kentucky, Mathematical Sciences
Lines: 42