Commit b9910041 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

fix(envsubst): leave lines with '# nosubst' unchanged when substituting (used to be simply dropped)

parent cb2fdf1e
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -32,7 +32,11 @@ function tbc_envsubst() {
      }
      return enc
    }
    !/# *nosubst/ {
    /# *nosubst/ {
      print $0
      next
    }
    {
      orig_line = $0
      line = $0
      count_repl_in_line = 0
+11 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ function setup() {
  export ASCIICHARS=$'\t\n\r'" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~"
}

@test "no subst" {
@test "no subst pattern" {
  # GIVEN

  # WHEN
@@ -39,6 +39,16 @@ function setup() {
  assert_equal "$RESULT" '<<<basic>>>'
}

@test "nosubst prevents subst" {
  # GIVEN

  # WHEN
  RESULT=$(echo -e 'subst: ${VAR_BASIC}\nnosubst: ${VAR_BASIC} # nosubst' | tbc_envsubst)

  # THEN
  assert_equal "$RESULT" "subst: basic${CR}nosubst: \${VAR_BASIC} # nosubst"
}

@test "basic percent" {
  # GIVEN