Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: command substitution: zsh waits until command exits



On Dec 4,  3:03am, Vincent Lefevre wrote:
} Subject: Re: command substitution: zsh waits until command exits
}
} > } #!/usr/bin/env zsh
} > } 
} > } echo foo | tee \
} > }   $({ xterm -e 'zsh -fic "tty >&3 ; exec sleep 99999999"' 3>&1 & } | read -E)
} > } 
} > } and run it, then lots of xterms are started recursively!
} > 
} > What did you name the script?  I can't reproduce this.
} 
} I've found the problem: this comes from the line
} 
}   SHELL=${0#-}
} 
} I have in my ".zshenv". Somewhere .zshenv is sourced with $0 having
} the name of the script. Is there any reason?

I suspect that first

#!/usr/bin/env zsh

starts a shell which doesn't have -f and therefore reads .zshenv and
sets SHELL to the name of the script, and *then* xterm starts $SHELL
to intepret its -e option.  The problem with using "env" in that way
is that you can't provide any options to the command.

Try it this way, where the -e option is not a quoted string:

------------------
#!/usr/bin/env zsh

echo foo | tee \
$({ xterm -e zsh -fic "tty >&3 ; exec sleep 99999999" 3>&1 & } | read -E)
------------------

If that doesn't work, explicitly reset SHELL:

------------------
#!/usr/bin/env zsh
SHELL=$(/usr/bin/env zsh)
echo foo | tee \
$({ xterm -e 'zsh -fic "tty >&3 ; exec sleep 99999999"' 3>&1 & } | read -E)
------------------



Messages sorted by: Reverse Date, Date, Thread, Author