/etc/grub.d/41_customはどのように機能しますか?

/etc/grub.d/41_customはどのように機能しますか?

/boot/grub/grub.cfg ファイルの一部が次のようになっているので尋ねます。

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
    source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
    source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

grub2に "source"コマンドがないため、これがどのように機能するのかわかりません。
http://www.gnu.org/software/grub/manual/grub.html

/bin/sh シェルコマンドの場合はソースです。
私の考えでは、/boot/grub/grub.cfg
のビルド中に、このコードスニペットに$ {config_directory} / custom.cfgを含める必要があります(grub-mkconfigを使用)。

[user@localhost ~]$ cat /etc/grub.d/41_custom 
#!/bin/sh
cat <<EOF
if [ -f  \${config_directory}/custom.cfg ]; then
    source \${config_directory}/custom.cfg
elif [ -z "\${config_directory}" -a -f  \$prefix/custom.cfg ]; then
    source \$prefix/custom.cfg;
fi
EOF

しかし、それは真実ではありません!
「source」コマンドを使用してテキストを挿入するだけです。

ベストアンサー1

マッピングの説明です。注文するmodulename.modへ
http://blog.fpmurphy.com/2010/06/grub2-modules.html?output=pdf

grep -E "^source" /boot/grub/i386-pc/command.lst
source: configfile

grep -E "^\.:" /boot/grub/i386-pc/command.lst
.: configfile

関数コードは次のとおりです。
http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/commands/configfile.c#n61

したがって、「source」は grub2 の文書化されていないコマンドに過ぎません。

おすすめ記事