zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: "Zsh users list" <zsh-users@sunsite.auc.dk>
Subject: Re: Problem w/ ulimit killing compiles on sol 2.4&2.6 ...
Date: Fri, 5 Feb 1999 00:28:14 -0800	[thread overview]
Message-ID: <990205002814.ZM21584@candle.brasslantern.com> (raw)

On Feb 5,  9:40am, Andrej Borsenkow wrote:
} Subject: RE: Problem w/ ulimit killing compiles on sol 2.4&2.6 ...
}
} >
} >   The only file you can alter which is started with every zsh (unless
} >   you use the -f option) is .zshenv, so this is a good place to
} >   put things you want even if the shell is non-interactive: options for
} >   changing the the syntax, like EXTENDED_GLOB,
} 
} I totally disagree. Anybody doing this will inevitably end up writing
} nonportable zsh scripts, that, when used on other system(s), will not work
} in the best or will have unpredictable side effects in the worst case.

We've had some discussions before about options that change the syntax,
IIRC in the context of which options could be "on" by default to better
showcase the multitude of zsh's talents.  It was concluded that the only
safe options to play with were the ones that changed purely interactive
features, like completion.

Quite obviously system administrators should be strongly discouraged from
using options that change the shell syntax in *any* of the global init
files, without extremely good reason.  An example of such a good reason:
using CSH_JUNKIE_PAREN in global files for zsh 2.5, when an incompatible
syntax change was introduced in the shell itself, which broke everyone's
personal init files.  (That option is now gone and the syntax restored.)

However, given that options to change the syntax exist at all, I can't
find fault with whichever of a users *personal* init files contain those
options.  Most users are going to write scripts and shell functions using
commands that work in their own interactive environment, and then will
expect them to work the same way in non-interactive shells started with
e.g. "rsh host command".  The only way to assure that this works is to
put the necessary settings in .zshenv.

"Writing nonportable zsh scripts" is a complete red herring.  The only way 
to write a portable zsh script is to begin the script with

    emulate -R zsh
    setopt ...		# whatever options the script needs, if any

If those lines are missing, the script is going to break eventually.  If
they're present, the script is immune to options set in the init files.
That's why the "emulate zsh" command was added in the first place.

Of course, you could still get messed up by aliases or functions that have
the same names as utilities, or named directory hashing, or a bogus $path.  
That's what you get for using an interpreted language.  The paranoid may
begin all scripts with

	#!/bin/sh

Then even /etc/zshenv won't be sourced.

} Scripts should _not_ depend on particular option(s) preset or, for
} that matter, on particular function(s) being available.

This is an excellent rule when writing scripts for public consumption.
It's unrealistic to apply it to an average user writing scripts for his
own convenience.  (Heck, even /etc/rc.d/init.d/* depend on being having
certain variables set and on using functions that are loaded by `.'-ing
other files.)  Perhaps, however, the FAQ should make a stronger point
that there are possible unintended side-effects of using .zshenv.

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


             reply	other threads:[~1999-02-05  8:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-05  8:28 Bart Schaefer [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-02-05  9:02 Peter Stephenson
1999-02-05  6:40 Andrej Borsenkow
1999-02-04 13:11 Peter Stephenson
1999-02-04  8:46 Peter Stephenson
1999-02-03 19:23 Bart Schaefer
1999-02-03 18:48 Sweth Chandramouli
1999-02-03 18:29 Greg Sylvain
1999-02-03 18:09 Greg Sylvain
1999-02-03 17:54 Bart Schaefer
1999-02-03 17:38 Greg Sylvain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=990205002814.ZM21584@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).