This is either dead simple or can’t be done, but after hours of looking I’m stumped. Just started using bash for an Apple script.
show_name=${BASH_REMATCH[1]} #show_name is declared
test "$show_name" == "Smash" && {show_name="Smash (2012)"} #redeclare the value from 'Smash' to 'Smash (2012)
Also tried some variations e.g.
test "$show_name_temp" == "Smash" && (show_name="Smash (2012)"; exit 1)
However the value show_name never gets redeclared. The if statement is definitely working because if I put an echo “hello, world” in, it prints.
I’m coming from PHP though, so my desktop syntax is lacking.
Thanks guys
AFAIK, the first is syntax error.
The second, the round parens will introduce another context, so any variables defined there won’t be visible outside it. What happens in parens stays in parens.
I believe you want this: