[GoLUG] Piping, redirection and shellscipts: 3/5/2025 7pm Eastern Standard time
Steve Litt
slitt at 444domains.com
Wed Mar 5 17:11:16 EST 2025
On Wed, 5 Mar 2025 13:30:17 -0800
Ron <admin at bclug.ca> wrote:
> Steve Litt wrote on 2025-03-05 13:26:
>
> >> echo "${PIPESTATUS[*]}"
> >>
> > This is immensely cool, if you use bash.
>
>
> If you are using zsh, the array is called pipestatus (case matters!)
> and the array indices start at one:
>
> $ false | true
> $ echo "${pipestatus[1]} ${pipestatus[2]}"
> 1 0
>
I use ksh for shellscripts, bash for interactive. Some of my older
shellscripts are /bin/sh, which on most Linux machines is dash. If you
know a way to make pipestatus work on ksh? My research tells me the
closest you get is
set -o pipefail
As described at
https://stackoverflow.com/questions/35463581/kornshell-equivalant-of-pipestatus
I'll be trying out set -o pipefail in the near future.
Thanks,
SteveT
Steve Litt
Spring 2023 featured book: Troubleshooting Techniques of the Successful
Technologist http://www.troubleshooters.com/techniques
More information about the GoLUG
mailing list