/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에 대한 문서화되지 않은 명령일 뿐입니다.

답변2

gnu.org 웹사이트의 Grub 2.02 매뉴얼은 16.3.71의 "명령줄 및 메뉴 입력 명령" 섹션에 있는 "source" 명령에 대한 문서를 제공합니다. 따라서 2017년 4월 25일(Grub 매뉴얼의 현재 버전 날짜) 현재 소스 명령이 문서화되었으며 현재 Linux MINT 19의 /etc/grub.d/41_custom 파일에서 사용되는 것을 발견했습니다. 분포 .

관련 정보