Saya sedang membaca “BASH pocket guide of Oreilly”.
Dikatakan:
ID proses dari proses Bash saat ini.
Dalam beberapa kasus, ini dapat berbeda dari $$.
Penjelasan di atas, dijelaskan $BASHPID
variabel.
Pertanyaan: kasus yang mana?
Jawaban yang Diterima:
Contoh disediakan di BASHPID
deskripsi halaman manual bash:
BASHPID
Expands to the process id of the current bash process. This
differs from $$ under certain circumstances, such as subshells
that do not require bash to be re-initialized.
Berikut adalah contoh subkulit yang mengeluarkan isi variabel, bersama dengan $$
dan isi BASHPID
di luar subkulit.
$ echo $(echo $BASHPID $$) $$ $BASHPID
25680 16920 16920 16920
# | | | |
# | | | -- $BASHPID outside of the subshell
# | | -- $$ outside of the subshell
# | -- $$ inside of the subshell
# -- $BASHPID inside of the subshell
Pengaturan Di Bash Untuk Globbing, Untuk Mengontrol Apakah * Cocok dengan File Dot?
Ny Cara Mencetak Nilai Di Dalam Variabel Di Dalam Kutipan Tunggal?