Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: More verbose && ?
- X-seq: zsh-users 14721
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: Richard Hartmann <richih.mailinglist@xxxxxxxxx>
- Subject: Re: More verbose && ?
- Date: Wed, 20 Jan 2010 17:10:20 +0000
- Cc: zsh-users@xxxxxxx
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent; b=GUbXIGOsaTfVSHV4VFm+7tVjlehg49npMbWw+KSp+A/FHijsdJtFCdFl+al5O/MyXm6D++5vVKHRYyOnqnt9msmEe1/DBYq2jBVehbz4T0fNOgCQ2+FDjibIUzMtlbJzpbpyP+rUbcOlJiOTFaR4hhSxLzIJWe3zDrRCyyhLIyE= ;
- In-reply-to: <2d460de71001200834i7037df54h647f7b01d6ebdc4@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: Richard Hartmann <richih.mailinglist@xxxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <2d460de71001200834i7037df54h647f7b01d6ebdc4@xxxxxxxxxxxxxx>
2010-01-20 17:34:38 +0100, Richard Hartmann:
> Hi all,
>
> I am wondering if there is a way to make && more verbose. Specifically,
> I am interested in where it failed in case it does.
>
> Consider this, admittedly crafted, example:
>
>
> rm dontexist
> touch exist
> echo yes && cat exist 2>/dev/null && cat dontexist 2>/dev/null && echo no
>
>
> This will not tell you _where_ it failed, just that it did (and even
> that only implicitely via return codes). I would prefer something along
> the lines of:
>
>
> Error executing "echo yes && cat exist 2>/dev/null && cat dontexist
> 2>/dev/null && echo no": "cat dontexist" failed.
>
> Or just
> Error(1): "cat dontexist"
>
>
> (1) being the, optional, return code being displayed.
[...]
try:
r() { last_run_command=${(j: :)*}; "$@"; }
report() {
exit_code=$?
printf >&2 'Error(%d): "%s"\n' "$exit_code" "$last_run_command"
return "$exit_code"
}
r echo yes &&
r cat exist 2>/dev/null &&
r cat dontexist 2>/dev/null &&
echo no || report
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author