0

We are calling bash script from Jenkinsfile which evaluates boolean parameter for running authentication script:

#!/bin/bash -eu
some case statements 
esac
$APP_PARAM:-} && key_aliase="xyz/aaa"
some parameter set
call another shellscript

and wondering what $APP_PARAM:-} && key_aliase="xyz/aaa" means. APP_PARAM is boolean parameter with default value false.

codeforester
  • 39,467
  • 16
  • 112
  • 140

1 Answers1

0

First, it's a typo for

${APP_PARAM:-} && keyaliase="xyzzy/aaa"

The result is that either $APP_PARAM expands to a program to run, and key_aliase is set only if the program succeeds, or the parameter expands to an empty string which, since it is unquoted, becomes a "null" command that is considered to succeed unconditionally.

Given that ${APP_PARAM} and ${APP_PARAM:-} produce the same result when expanded, I assume that the script uses set -u to exit on any attempt to expand an undefined parameter. The latter form expands to an empty string instead of triggering the exit.

chepner
  • 497,756
  • 71
  • 530
  • 681