-1

I have a variable called boiler,

boiler='#!/bin/bash
source ../../functions.sh
current="${si1}"
ready custom
title
breadcrumbs \""$current"\" \"Options\"
# END OF BOILER (DO NOT REMOVE ABOVE CODE OR MODIFY IT)
'

ISSUE and EXPECTED OUTPUT

The issue is that i want everything to be ignored withing this string (aka printed raw) except for the ${si1} variable. How could I concatenate the first part the variable and then the rest of the string, while keeping it minimal and saving it back into the boiler variable?

Barmar
  • 669,327
  • 51
  • 454
  • 560
TroopekYT
  • 93
  • 7

1 Answers1

0

You can delimit the string around ${si1}.

boiler='#!/bin/bash
source ../../functions.sh
current='"${si1}"'
ready custom
title
breadcrumbs \""$current"\" \"Options\"
# END OF BOILER (DO NOT REMOVE ABOVE CODE OR MODIFY IT)
'

This is ordinary string concatenation. The strings delimited with ' will be literal, while the string delimited with " will have the variable expanded.

Difference between single and double quotes in Bash

Barmar
  • 669,327
  • 51
  • 454
  • 560
  • And will it still be stored within the boiler variable? – TroopekYT May 02 '22 at 09:47
  • Of course. This is just string concatenation. We use `'` around the strings we don't want variables replaced in, and `""` around the strings that should be. – Barmar May 02 '22 at 14:48