Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Apple bash to zsh script problems with error control and bash emulation
- X-seq: zsh-users 26173
- From: Dominik Reichardt <domiman@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Apple bash to zsh script problems with error control and bash emulation
- Date: Mon, 16 Nov 2020 20:45:53 +0100
- Archived-at: <https://zsh.org/users/26173>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2020-11/4254F6E5-249B-4DFF-8D4D-6D253D15AFB2%40gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-wr1-f50.google.com) smtp.remote-ip=209.85.221.50; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=MhErchVxV/EiVrYc1HSQviohHbv+Br0Sk1pTrDWINPQ=; b=HLe+GoV8hdySfdB97Rcv7Si6fhxB4t2GQFXo0UtPdnl1m5QIA5vOOzrMTs0GBvAT2J Z0AhcIk9c0JAidznvuMNGZ/IkhItYCrqIx9by+vrKpBth8QFEdTooi3lV2v9DgppexvD nPVjc7qjFtT+PGB1fjZH19MFtPCTYA6taqJKc2NU5lV649+aOprH7LKYn2tgi2Ksolj5 XYxC982wkKHmPtN8XX15ER7L69ae3iwlUYdCN5c/yDbD/hd5mVTLAI3ShQXhxxYHjebu LNvfTiZW0VxELosrtYc5T/zAmRa6G+VFwW2mvbgN5eGkpw7BCDOoVEA4yb5VamAo6K7s h1MQ==
- In-reply-to: <20201116180129.4f6a851f@tarpaulin.shahaf.local2>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-users>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-users.zsh.org>
- List-owner: <mailto:zsh-users-request@zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-users>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-users>
- References: <1EFC2452-32D1-411C-B239-0031131FA197@gmail.com> <20201116180129.4f6a851f@tarpaulin.shahaf.local2>
- Sender: zsh-users-request@xxxxxxx
> On 16. Nov 2020, at 19:01, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Dominik Reichardt wrote on Mon, 16 Nov 2020 16:00 +0100:
>> I’ve recently moved to zsh as Apple is pressuring us :)
>>
>
> The easiest solution is to keep the script as «#!/usr/bin/env bash»:
>
> https://github.com/zsh-users/zsh/blob/04bd9a44a74683ad0d83921bfb3aa0c4d5992c75/Etc/FAQ.yo#L2056-L2102
oddly enough, this doesn’t seem to work as expected with my old script on both macOS 10.15 and 11.0. Several things I declare in the function.sh seems as if they don’t exist.
For example that "alias autogen='./autogen.sh > /dev/null 2>&1’”, when I run the script it returns "./exultsnapshot.sh: line 45: autogen: command not found”.
Something changed...
>
>> Something goes wrong in the error(), pipestatus() and teelog() functions, I guess. But I can’t quite tell and I’ve built that script 5 years ago and am a bit rusty to what each of those function do exactly.
>
> Well, for starters, $PIPESTATUS doesn't expand to what you think it
> does.
I fixed this behaviour when I turned off bash emulation and used the lower case pipestatus[@] in my function. Seems that didn’t work correctly either way in the bash emulation and thus disturbed my error() function. Now it works again and prints me the error of which command in my build() function failed and then exits the script.
>
>> What I expect is that when the script runs into an error it stops, even if the error happens in one of the functions but currently the script goes on and on. This used to work before in bash.
>
> See «set -e». You probably have it set in your bash global setup.
>
> See also the ERR_RETURN option.
>
>> If I get rid of the —emulate sh, my variables don’t get passed on correctly (the error I get in the shorted version of my script is "configure: error: unrecognized option: `-q --disable-data --with-macosx-static-lib-path=/opt/i386/lib’”
>>
>
> http://zsh.sourceforge.net/FAQ/zshfaq03.html#l18
Thanks, I have to confess I understood only parts of it, but seems that using $CONF_OPT $CONF_ARGS as ${=CONF_OPT} ${=CONF_ARGS} fixed my woes.
So now the script runs as expected again without bash emulation! Wheee!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author