2025年2月20日(木) 23:37 Chet Ramey <chet.ra...@case.edu>: > > $ bash --pretty-print -O extglob test.sh > > You can use BASH_ENV for this. The primary reason that pretty-printing mode > doesn't suppress execution until after any startup files are read is to > allow a custom startup file to set the shell options you want for printing.
Thank you. I didn't know this behavior. Is that documented? I tried to find it in the description of `--pretty-print', but I realized that the --pretty-print option itself is undocumented. Then, I tried to check the description of the `-n' option, but I noticed that BASH_ENV is not used by `bash -n'. For `bash -n', it seems a user still needs to specify `-O extglob' even when they globally enable extglob' in BASH_ENV. Another way seems to be to set extglob through the environment variable BASHOPTS, which works for both `-n' and `--pretty-print'. $ env BASHOPTS=extglob bash --pretty-print test.sh $ env BASHOPTS=extglob bash -n test.sh -- Koichi