zsh-workers
 help / color / mirror / code / Atom feed
* Question on unintuitive behaviour for function execution and parameter assignment
@ 2021-10-12  8:20 Jett Husher
  2021-10-12  8:31 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Jett Husher @ 2021-10-12  8:20 UTC (permalink / raw)
  To: zsh-workers

Good day!

Does a function `assign-hello` treat parameter assignment on simple command as local parameter in the following code snipped?

```
HELLO=WORLD

function assign-hello() HELLO=$1

assign-hello THERE
echo $HELLO # Prints 'THERE', as expected

# This part trips me up
HELLO= assign-hello WHY
echo $HELLO # Why does it still print 'THERE'?
```

POSIX spec says that parameter assignment with function execution will alter the current shell environment and that it's not specified what's going to happen with this parameter at the end of the execution. `zshmisc(1)` in FUNCTIONS states that functions are called on a parent process, so my intuition was that this sort of code should not work for them. Unfortunately, I could not find any more information about this in the manuals or FAQs.

Can manuals be updated to cover this behaviour, please?

Thank you for your time.
- Jett


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

end of thread, other threads:[~2021-10-13  9:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12  8:20 Question on unintuitive behaviour for function execution and parameter assignment Jett Husher
2021-10-12  8:31 ` Peter Stephenson
2021-10-13  8:42   ` Jett Husher
2021-10-13  9:10     ` Peter Stephenson

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