[comp.unix.shell] using set in a csh script

martha@cs.umass.edu (Martha S. DasSarma) (10/25/90)

	I am trying to do set a variable that includes spaces, but the
	set deletes them.
	I type:

	$ set t="Mon   5"
	$ echo $t
	$ Mon 5

	What happens is that the set deletes the extra spaces I put 
	in the set.
	How could I preserve the spaces?

	Any help will be appreciated.

	Thanks,

	Martha DasSarma


------

Martha DasSarma, Research Computing Facility, COINS, UMass/Amherst
internet: martha@cs.umass.edu

jik@athena.mit.edu (Jonathan I. Kamens) (10/25/90)

In article <21752@dime.cs.umass.edu>, martha@cs.umass.edu (Martha S. DasSarma) writes:
|> 	What happens is that the set deletes the extra spaces I put 
|> 	in the set.

  Wrong.  The spaces are not deleted when you do the set, they are deleted
when you do the echo, since the echo command echoes each of its arguments,
separating each of them by one space.

	% set t="Mon   5"
	% echo $t
	Mon 5
	% echo "$t"
	Mon   5

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710

epames@eos.ericsson.se (Michael Salmon) (10/25/90)

In article <21752@dime.cs.umass.edu> martha@cs.umass.edu (Martha S. DasSarma) writes:
>
>	I am trying to do set a variable that includes spaces, but the
>	set deletes them.
>	I type:
>
>	$ set t="Mon   5"
>	$ echo $t
>	$ Mon 5
>
>	What happens is that the set deletes the extra spaces I put 
>	in the set.
>	How could I preserve the spaces?

Set hasn't deleted the spaces, they were deleted in the parsing of echo, just as if
you typed $ echo Mon   5. Try $ echo "$t".

Regards
   Michael Salmon

kole@convex.com (John P. Kole) (10/26/90)

>>	$ set t="Mon   5"
>>	$ echo $t
>>	$ Mon 5
>>

You might try this:

	% set t="Mon   5"
	% echo $t:q
	% Mon   5