zsh-users
 help / color / mirror / code / Atom feed
* using the "source" command in a "for" loop
@ 1997-01-02 20:08 Timothy J Luoma
  0 siblings, 0 replies; 5+ messages in thread
From: Timothy J Luoma @ 1997-01-02 20:08 UTC (permalink / raw)
  To: zsh-users


I was using this with "zsh-2.6-beta13" in .zshenv

export ZDOTDIR=$homedir/Unix/zsh/source/

for i in `/bin/ls -1 $ZDOTDIR`
do
        echo -n "Sourcing $i... "

        # source the file
        source "$ZDOTDIR/$i"

        # set up variables using the filenames
        $i="$ZDOTDIR/$i"
        echo "done"
done

now with 3.0.2 I get this:

/Users/luomat/.zshenv: no such file or directory:  
aliases=/Users/luomat/Unix/zsh/source//aliases [91]

(where "aliases" is a filename)

this was a handy thing, where I could add or remove files to be  
sourced simply by putting them in or taking them out of the folder.

AND I also got a variable made at the same time, which was handy  
because then I could do "pico $aliases" rather than "pico  
$ZDOTDIR/aliases" which I always seem to fumble over.

Is there a new way to do this?  What am I doing wrong?

Thanks!

TjL

--
	Tj Luoma (luomat@peak.org)
		http://www.next.peak.org/~luomat
			Awaiting Apple's NeXTStep


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using the "source" command in a "for" loop
  1997-01-03  0:19     ` Timothy J Luoma
@ 1997-01-03  0:51       ` Zoltan Hidvegi
  0 siblings, 0 replies; 5+ messages in thread
From: Zoltan Hidvegi @ 1997-01-03  0:51 UTC (permalink / raw)
  To: luomat; +Cc: greg, zsh-users

Timothy J Luoma wrote:
> > eval $i='"$ZDOTDIR/$i"'
> 
> Is there any reason to use "eval" over "export"?

export sets the environment which eval doesn't which means tha export
requires a bit more memory and it will increase the size of every child
processes a little bit afterwards.  And some environment variables have
special meanings to applications.

Zoltan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using the "source" command in a "for" loop
  1997-01-02 23:12   ` Zoltan Hidvegi
@ 1997-01-03  0:19     ` Timothy J Luoma
  1997-01-03  0:51       ` Zoltan Hidvegi
  0 siblings, 1 reply; 5+ messages in thread
From: Timothy J Luoma @ 1997-01-03  0:19 UTC (permalink / raw)
  To: Zoltan Hidvegi; +Cc: greg, zsh-users

Responding To:	Zoltan Hidvegi <hzoli@cs.elte.hu>
Original Date:	Fri, 3 Jan 1997 00:12:48 +0100 (MET)
Message-ID: 	<199701022312.AAA00632@hzoli.ppp.cs.elte.hu>

> The first version does not work because zsh tries to assign the
> parameter named `$i'. You have to use eval to assign the value of
> $i. Although this worked without eval up to zsh-3.0.0 it was never
> documented. You can use
>
> eval $i='"$ZDOTDIR/$i"'

Is there any reason to use "eval" over "export"?

Thanks

TjL

--
	Tj Luoma (luomat@peak.org)
		http://www.next.peak.org/~luomat
			Awaiting Apple's NeXTStep


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using the "source" command in a "for" loop
  1997-01-02 21:12 ` Timothy J Luoma
@ 1997-01-02 23:12   ` Zoltan Hidvegi
  1997-01-03  0:19     ` Timothy J Luoma
  0 siblings, 1 reply; 5+ messages in thread
From: Zoltan Hidvegi @ 1997-01-02 23:12 UTC (permalink / raw)
  To: luomat; +Cc: greg, zsh-users

> > # need to export the vars, or they're lost when leaving the loop

No, they are not lost.

> I guess something changed because this even worked for 3.0.0.  No  
> matter, as long as it works now
> 
> I changed:
> 	$i="$ZDOTDIR/$i"
> to
> 	export $i="$ZDOTDIR/$i"

The first version does not work because zsh tries to assign the parameter
named `$i'.  You have to use eval to assign the value of $i.  Although this
worked without eval up to zsh-3.0.0 it was never documented.  You can use

eval $i='"$ZDOTDIR/$i"'

Zoltan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using the "source" command in a "for" loop
       [not found] <3.0.32.19970102160304.0098b380@ns1.iweb.net>
@ 1997-01-02 21:12 ` Timothy J Luoma
  1997-01-02 23:12   ` Zoltan Hidvegi
  0 siblings, 1 reply; 5+ messages in thread
From: Timothy J Luoma @ 1997-01-02 21:12 UTC (permalink / raw)
  To: greg haygood; +Cc: zsh-users

Responding To:	greg haygood <greg@iweb.net>
Original Date:	Thu, 02 Jan 1997 16:03:05 -0500
Message-ID: 	<3.0.32.19970102160304.0098b380@ns1.iweb.net>

> # need to export the vars, or they're lost when leaving the loop

Your fix worked.

I guess something changed because this even worked for 3.0.0.  No  
matter, as long as it works now

I changed:
	$i="$ZDOTDIR/$i"
to
	export $i="$ZDOTDIR/$i"

Thanks!

TjL

--
	Tj Luoma (luomat@peak.org)
		http://www.next.peak.org/~luomat
			Awaiting Apple's NeXTStep


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1997-01-03  1:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-02 20:08 using the "source" command in a "for" loop Timothy J Luoma
     [not found] <3.0.32.19970102160304.0098b380@ns1.iweb.net>
1997-01-02 21:12 ` Timothy J Luoma
1997-01-02 23:12   ` Zoltan Hidvegi
1997-01-03  0:19     ` Timothy J Luoma
1997-01-03  0:51       ` Zoltan Hidvegi

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).