有趣的bash脚本随记:修订间差异

来自三线的随记
无编辑摘要
无编辑摘要
第20行: 第20行:
  EOT
  EOT
  done
  done
<br />
<br />https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion
[[分类:Todo]]
[[分类:Todo]]
[[分类:Linux]]
[[分类:Linux]]
[[分类:Bash]]
[[分类:Bash]]
{{DEFAULTSORT:interesting}}
{{DEFAULTSORT:interesting}}

2020年12月25日 (五) 11:47的版本

domains="${!PARSOID_DOMAIN_*} ${!PARSOID_MWAPIS_*}"

if [ -z "$domains" ]; then
    echo >&2 'You must provide PARSOID_DOMAIN_* variables, for example: export PARSOID_DOMAIN_localhost=http://localhost/w/api.php'
    exit 2;
fi


# see https://www.mediawiki.org/wiki/Parsoid/Setup#Configuration
for var in $domains
do
    if [ -z "${!var}" ]; then
        echo >&2 "The $var variable must not be an empty string";
    fi

    cat <<EOT >> config.yaml
          -
            uri: '${!var}'
            domain: '${var:15}'
EOT
done


https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion