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

来自三线的随记
无编辑摘要
无编辑摘要
 
第1行: 第1行:
cd "$(dirname "${BASH_SOURCE[0]}")"
<br />
  domains="${!PARSOID_DOMAIN_*} ${!PARSOID_MWAPIS_*}"
  domains="${!PARSOID_DOMAIN_*} ${!PARSOID_MWAPIS_*}"
   
   

2021年1月9日 (六) 00:04的最新版本

cd "$(dirname "${BASH_SOURCE[0]}")"


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