Greg Wooledge wrote in
 <yrt2m2dilqqae...@wooledge.org>:
 |On Thu, Jun 23, 2022 at 05:58:23PM -0400, Chet Ramey wrote:
 |> On 6/23/22 5:08 PM, Steffen Nurpmeso wrote:
 |>>    bash -c 'if [ ! ! hey = hey ]; then echo du; fi'
 |
 |> Sure. This one isn't a common idiom for shell programmers, apparently.
 |
 |I've seen it used in a math context, inside PS1.  Like so:
 |
 |color=(
 |  "$(tput setaf 2)"  # 0 = green
 |  "$(tput setaf 1)"  # 1 = red
 |)
 |normal="$(tput sgr0)"
 |PS1='\[${color[!!$?]}\]$?\[$normal\] \h:\w\$ '
 |
 |This writes the previous command's exit status in either green or red.
 |It "smashes" all nonzero exit codes to 1, using a double negation in
 |a C-style arithmetic context, in order to generate an array index for
 |the color.
 |
 |I don't recall ever seeing it used in the way Steffen showed, though.

Because the devil is in your car!
That always makes a subdivision.

Other than that just dance this mess around.

 --End of <yrt2m2dilqqae...@wooledge.org>

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

Reply via email to