Issue
I'm trying to understand some code. There is a Array declared called "Choices" which is used in a in a function called SetChoices. Then this function is called later on, with this
SetChoices "${@//\\//}"
I'm not clear on what this is doing.
Thanks in advance
Solution
Syntax ${var/pattern/string}
is pattern substitution on shell variable.
If we run following script:
x="ABCfooDEF"
echo "${x/foo/bar}"
The output will be ABCbarDEF
.
$@
- this means all arguments, so ${@//\\//}
means:
in @
replace all \
(in script is \\
, because it's escaped backslash) with /
.
Answered By - Jorengarenar Answer Checked By - Cary Denson (WPSolving Admin)