zsh-workers
 help / color / mirror / code / Atom feed
* Re: sourcing of /etc/profile with $0 == -sh
       [not found] <003801bd904c$4df7c680$21c9ca95@ao13.mow.sni.de>
@ 1998-06-05  7:39 ` Peter Stephenson
  1998-06-05  8:22   ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 1998-06-05  7:39 UTC (permalink / raw)
  To: Zsh hackers list; +Cc: Andrej Borsenkow

"Andrej Borsenkow" wrote:
> In my /etc/zprofile I source /etc/profile. Unfortunately, it contains code
> depending of shell (that is, case $0 in -sh | -ksh ...). I don't want to
> mess up with system /etc/profile, so I tried to find a way to set $0 only
> for the time of sourcing. Currently I use (zsh-3.1.4):

I don't think you even need to make it local, since $0 is handled
similarly to the other positional arguments.

% fn() { 0=foo; echo $0; }  
% fn
foo
% echo $0
zsh

This fact should probably be construed as a genuine feature.  If you're
asking, is some bright spark going to decide that $0 should be different
from $1 to $infinity and break it, I can't answer that, but it won't be me.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +39 50 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy


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

* Re: sourcing of /etc/profile with $0 == -sh
  1998-06-05  7:39 ` sourcing of /etc/profile with $0 == -sh Peter Stephenson
@ 1998-06-05  8:22   ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1998-06-05  8:22 UTC (permalink / raw)
  To: Peter Stephenson, Zsh hackers list; +Cc: Andrej Borsenkow

On Jun 5,  9:39am, Peter Stephenson wrote:
} Subject: Re: sourcing of /etc/profile with $0 == -sh
}
} % fn() { 0=foo; echo $0; }  
} % fn
} foo
} % echo $0
} zsh
} 
} This fact should probably be construed as a genuine feature.  If you're
} asking, is some bright spark going to decide that $0 should be different
} from $1 to $infinity and break it, I can't answer that, but it won't be me.

Actually, Peter, you're already too late.  That had better be

	fn() {
	  setopt functionargzero
	  0=foo
	  echo $0
	}

Otherwise, assigning to 0 in the function assigns to the "global" $0.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

end of thread, other threads:[~1998-06-05  8:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <003801bd904c$4df7c680$21c9ca95@ao13.mow.sni.de>
1998-06-05  7:39 ` sourcing of /etc/profile with $0 == -sh Peter Stephenson
1998-06-05  8:22   ` Bart Schaefer

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).