I'm reading a bash script function which takes an input variable with escape codes as first parameter and cycles on its characters, anyway I can't understand these lines:
local input="${1//\"/\\\"}" output="" i char within_code=0
for ((i=0; i < ${#input}; ++i)); do
char="${input:i:1}" # get current character
I guess my bash-foo isn't strong enough.
"${1//\\"/\\\\\\"}"
? The first parameter should be $1
I think.#
in ${#input}
do? The rest I can, more or less, understand.
The expansions are explained in the bash manual Shell Parameter Expansion .
"
with \\"
in $1
. Yes, $1
expands to the first positional parameter.${#input}
expands to the length of $input
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.