zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Michael Wardle <michael@endbracket.net>
Cc: zsh-workers@sunsite.dk
Subject: Re: problem redeclaring path variable (ksh incompatibility)
Date: Fri, 18 Mar 2005 02:42:16 +0000	[thread overview]
Message-ID: <1050318024216.ZM575@candle.brasslantern.com> (raw)
In-Reply-To: <4239F9E1.5070009@endbracket.net>

On Mar 18,  8:42am, Michael Wardle wrote:
} Subject: Re: problem redeclaring path variable (ksh incompatibility)
}
} > Try running your test script with ARGV0=sh in the environment and note
} > the difference in behavior.
} 
} It didn't appear to make any difference.

Er, I was assuming, because you were posting to a zsh mailing list, that
your usual shell was zsh, which is possibly a bad assumption.  That is,
ARGV0 is magic to zsh -- not to the new zsh being started up, but to the
currently running zsh that is printing your PS1 prompt.  If your login
shell is bash or ksh, the ARGV0=sh isn't going to make any difference.

So, first start an interactive zsh, and then from the prompt of that,
run "ARGV0=sh zsh -p yourtestscript", and NOT "ARGV0=sh yourtestscript".

Or, do "ln -s `which zsh` /tmp/sh" and then "/tmp/sh -p yourtestscript".

} Are you sure this hides $path

It causes it never to become set in the first place.

} or are you just suggesting this should be the normal way to invoke zsh 
} any time I want it to conform closely to POSIX shell?

If you want zsh to conform closely to the POSIX shell you have to make a
link to it whose pathname ends in "sh" (actually any string starting with
the letter "s" other than "su" will work) and run it via that link.  The
trick with ARGV0 is a zsh-ism that simulates having done so.

} So this works:
} typeset path
} path=
} path="scalar"

This declares a local path, but it inherits the special features of the
global path.  It then makes it empty (redundant), and finally makes it
a single-element array.

} But this doesn't:
} typeset path=
} path="scalar"

It doesn't work because "typeset path=" fails *entirely* when it prints
the "can't assign initial value" error message; consequently you have
not succeeded in declaring "path" to be local, and the assigment affects
the global.

} And neither does this:
} typeset path=""
} path="scalar"

Same problem.

} > zsh% func() { emulate ksh; typeset path ; path=scalar ; typeset path }
} > zsh% func
} > path=(scalar)
} 
} Assuming a -m flag to the final typeset, this certainly verifies what 
} you said.

Right, I forgot the -m is required in 4.2.  I tried it in 4.0, in which
older version "emulate ksh" does not imply "setopt TYPESET_SILENT".


  reply	other threads:[~2005-03-18  2:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-17 14:31 Michael Wardle
2005-03-17 16:50 ` Bart Schaefer
2005-03-17 17:28   ` Bart Schaefer
2005-03-17 21:42   ` Michael Wardle
2005-03-18  2:42     ` Bart Schaefer [this message]
2005-03-18 10:52   ` Peter Stephenson

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=1050318024216.ZM575@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=michael@endbracket.net \
    --cc=zsh-workers@sunsite.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).