[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: jobs built-in command and PROMPT_COMMAND
From: |
Tapani Tarvainen |
Subject: |
Re: jobs built-in command and PROMPT_COMMAND |
Date: |
Sun, 3 Oct 2021 13:35:26 +0300 |
On Sun, Oct 03, 2021 at 01:20:49AM +0200, Christoph Anton Mitterer
(calestyo@scientia.net) wrote:
> On Fri, 2021-10-01 at 09:22 -0400, Greg Wooledge wrote:
> > > PS1='...$( [ -n "$(jobs)"] && printf '\j')...'
> > You can sidestep the prompt forks in most cases by using the value as
> > an array index, with a specially crafted array.
> But doesn't all that require an array with at least as many elements
> pre-set, as jobs my run?
As arrays return null for nonexistent indices, all you need is an
array with only zero index having a value. Using an empty string as
the value allows you to return nothing for zero and whatever you
desire for non-zero values of \j:
a=('')
PS1='${a[\j]-\j }$ '
--
Tapani Tarvainen