Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
タイトルで述べたように、次の bash スクリプトを機能させることは可能ですか?
#!/bin/bash echo_report() { echo "echo on line $1" } trap 'echo_report $LINENO' [sigspec] #same code here echo "hi" #more code here
何に使えばいいのかわからない[sigspec]…
[sigspec]
使用trapできない場合、他にどのようなオプションがありますか?
trap
echo関数でラップしcaller、行番号を表示するために使用します。
echo
caller
#!/bin/bash echo() { caller command echo "$@" } echo "hi"
結果:
$ bash foo.bash 8 foo.bash hi