Advanced Bash-Scripting Guide の第 2 章を読んでいて、このスクリプトについて脚注で読んでいました。
#!/bin/rm
# Self-deleting script.
# Nothing much seems to happen when you run this... except that the file disappears.
WHATEVER=85
echo "This line will never print (betcha!)."
exit $WHATEVER # Doesn't matter. The script will not exit here.
# Try an echo $? after script termination.
# You'll get a 0, not a 85.
通常rm
、引数を取り、そのファイルを削除します。ここでは、rm
実行中のスクリプトに基づいて行動することをどういうわけか知っています。これは、シェルが に遭遇すると#!
、そのファイルへの (完全修飾された?) パスを、 の後に指定されたプログラムへの引数として渡すことを意味します#!
か?